Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I am trying to add all text files in folder Source but get an exception error when I run the code.

I have used:

String sFile = "@c:\\Source\\*.txt";


Any help would be great.

Thanks in advance:confused:

Trot
Posted
Updated 25-Aug-10 7:48am
v2

Trot one problem is that you are using the "@" system which essentially means "ignore special characters and treat everything as a string literal". So what this means is...
string sFile = @"c:\Source\*.txt";

Should fix your first issue. Alternatively, you can remove the "@" and leave everything the same.

Dave
 
Share this answer
 
v2
Comments
trotter246 25-Aug-10 7:12am    
Thanks Dave, I tried this and still get the error, may be I sould have posted the other bit of code:-

String sFile = "c:\Source\*.txt";
MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
Unable to add comments. Getting some server error so posting as an answer.

Based on the comment to the answer:
Looks like you did not follow what David suggested.
Either use:
C#
string sFile = @"c:\Source\*.txt"; 

OR
C#
string sFile = "c:\\Source\\*.txt";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900