hi..
i am trying to pass the file path of a text file, which i need to read, to a file object so as to read all lines of the text file. and i am selecting the file through a filedialog and i obtained the filepath and the filename using the FileName and SafefileName properties of the filedialog ...as:
now i am facing problem in introducing the escape character to ignore the backslash punctuation while passing the filename in a string variable.
for understanding of the problem my code is like:
*********obtain ing the filename from filedialog property.
filepath = dialogbox.FileN ame;
filename = dialogbox.SafeF ileName;
*********here i am passing the filepath obtained above into the file object to read lines from it.
string[] lines = File.ReadAllLin es(filepath);
consider my filepath is like:
C:\Myfiles\abc. txt
now i want to introduce the escape character to the filepath string to make it like:
@"C:\Myfiles\ab c.txt"
or
C:\\Myfiles\\ab c.txt
so that i can pass this filepath string to the file object as shown above.
any idea would be very helpful..thanks a lot in advance..
i am trying to pass the file path of a text file, which i need to read, to a file object so as to read all lines of the text file. and i am selecting the file through a filedialog and i obtained the filepath and the filename using the FileName and SafefileName properties of the filedialog ...as:
now i am facing problem in introducing the escape character to ignore the backslash punctuation while passing the filename in a string variable.
for understanding of the problem my code is like:
*********obtain ing the filename from filedialog property.
filepath = dialogbox.FileN ame;
filename = dialogbox.SafeF ileName;
*********here i am passing the filepath obtained above into the file object to read lines from it.
string[] lines = File.ReadAllLin es(filepath);
consider my filepath is like:
C:\Myfiles\abc. txt
now i want to introduce the escape character to the filepath string to make it like:
@"C:\Myfiles\ab c.txt"
or
C:\\Myfiles\\ab c.txt
so that i can pass this filepath string to the file object as shown above.
any idea would be very helpful..thanks a lot in advance..
Comment