copy a file to a table in postgresql using C# npgsql driver and how to get a single \ when using path names -


I am trying to do a per-tab-delimited text file in a # e-drive from a server in # post in postgresql.

My SQL command

  NPGSQL COMMAND CMD = "NPGXLL COMMAND" ("Copy scrap (glove_post_date, stock_number, stock_description, reasoncode, adjusted_tk, unicast, extended_host, week, cost , Catch_Ol) "+ Filename +"; ", Conn);   

Here is my path code

  string r = @ "e: \"; String t = txtFileName.Text; Filename = r + t;   

I check my filename variable and it returns the path with a double backslash which I want to return to e: \ file.txt

I p < p> Thanks

The backslash has a special meaning in the string in C #, for example \ n is a new line, \ t is a tab ... and \\ is actually a backslash; these combinations of backslash and a character are esec The sequence is called. However, in your example, you used the so-called literally string literally. At the beginning of the string, @ means that a backslash should be considered as any other character within the string (it disables escape sequences). In other words, @ "e: \" is the same thing as "e: \\" and it's okay. See also articles and questions for more information.

I also suggest using the Path.Combine method to enter the drive name with a file name in a trusted way.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -