Skip to main content

Unique report export name?

Comments

3 comments

  • Permanently deleted user

    Hi Laura,

     

     Both the forward slash (/) and the colon (:) are invalid characters in a Widows file name. The replace fuction can be added to your string so that these characters are changed to something acceptable to Windows.

     

    Try:

    "C:\Inetpub\wwwroot\HED_Data\Report_" +company +DateTime.Now().ToString().replace("/","-").replace(":","_") + ".xls"

    This change will put dashes for forward slashes, and underscores for colons; you can change thse to other characters as long as they are valid for a filename.

    See http://msdn.microsoft.com/en-us/library/fk49wtc1(v=vs.110).aspx

     

    regards,

    Edmond

    0
  • Nico Burgerhart

    Or add something like this to the filename:

    DateTime.Now.ToString("_yyyyMMdd_HHmmss")

    0
  • Permanently deleted user

    Thanks everyone, It's now working perfect!

    0

Please sign in to leave a comment.