I work with files. And use code like this:
PdfWriter.GetInstance(newFile, new FileStream(WebConfigurationManager.AppSettings["StorageFolder"] + "\\" + DateTime.Now.Year.ToString() + "\\fnp\\request_" + myVariable+ "_l" + confirmLevel.ToString() + ".pdf", System.IO.FileMode.Create));
This line generates my file's full path. For example, if myVariable="0001"
then it is OK. So newFile's full path will be something like, say, StorageFolder\2016\fnp\request_0001_l2.pdf. But I want to assign myVariable value like myVariable = "0001/16"
. Then PdfWriter.GetInstance method tries to create path like StorageFolder\2016\fnp\request_0001\16_l2.pdf. But I need it to create StorageFolder\2016\fnp\request_0001/16_l2.pdf.
How can I manage it?
Well, you can't.
The /
character is not legal in foldernames or filenames on Windows.
You will have to pick another character instead, one that is legal.
You can read more about these things in this MSDN Article: Naming Files, Paths, and Namespaces:
Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following reserved characters:
<
(less than)
>
(greater than)
:
(colon)
"
(double quote)
/
(forward slash)
\
(backslash)
|
(vertical bar or pipe)
?
(question mark)
*
(asterisk)
+ some other details