0

I have created a web service to send emails with attachments. The attachment location is passed via a string called "StrAttachment". I can pass the actual location of the folder, but this service will run everytime a sale is made to email documents to a client. The location of the folder will always be "C:", but a new folder will be created everyday named by the date, for eg : 20121018. So I need to pass that name to the StrAttachment parameter, so my web service knows which folder to look in.

Any ideas?

user1668123
  • 105
  • 1
  • 1
  • 10

3 Answers3

1

You can set your parameter using DateTime.ToString() and specifying the format:

string StrAttachment = "C:\\" + //your drive letter
                       DateTime.Today.ToString("yyyyMMdd") +  //your current date
                       "yourFoldername"; //other name in the folder (if any)
Habib
  • 219,104
  • 29
  • 407
  • 436
1

Have a look here: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

It should be something like DateTime.Now.ToString("yyyyMMdd")

Dan Fox
  • 143
  • 8
0

You can get current date with DateTime.Today. You can use it to extract the formatted current data as

folderName = DateTime.ParseExact(DateTime.Today, "yyyyMMdd", CultureInfo.InvariantCulture).ToString("yyyyMMdd");

There is a quite similar question (well, it doesn't involve the folder part) Convert DateTime to string format("yyyyMMdd")

Community
  • 1
  • 1
Coral Doe
  • 1,925
  • 3
  • 19
  • 36