Double Backslash in File Path causing problems when reading from Config File

HI All,

I am trying to upload a document via ftp. It works with a normal local file path, but the file path I wish to upload looks like this and is saved in the config file:

\\networkfoldername\public\IT\Invoices\Invoice.pdf

I cannot show the real networkfoldername since this is my client. If i just enter this into the ftp it works but when I read this path from the config and it causes this:

\\\\networkfoldername\\public\\IT\\Invoices\\Invoice.pdf

This causes the upload to fail, anybody that can help me with the slashes?

hi @Tristan_Kok

you have to use full path like this
“C:\Users\Gulshiyaa\Desktop\sampleEnterpriseFramework.zip” in your config file

thank you
Regards,
gulshiyaa

Hi @Tristan_Kok and @gulshiyaa,

I also want to read a file on the network that ist defined in the config file. Therefore I want to use dynamic arguments for Drive_Letter, Drive_Path and File_Name. Without the Drive_Letter it works, but I don`t understand the handling of the “” in the path. Sometimes UIP doubles the “” and sometimes it is dismissed.
Does anyone understand the logic to use a dynamic path with the config file?

I appreciate your help, Michael

Hi @mipfi

When you have a space in the path, you need to keep the " around it. In VB, you do it by doubling them

A string ""my path/to a dir with space"" will be interpreted as "my path/to a dir with space"

EDIT: please note that if your path don’t have space surrounding it with quote is valid. A path with a space not surrounded by quotes will trigger an exception.

Hi @msan, thank you for your answer. I just noticed that there is a mistake in my post, the backslash is missing. I meant the backslashes in the path, for example x:\server\Folder. UIP doubles the backslashes and I can`t control it when I use the path information in the config file.
What is to do with the backslaches \ in the config file ?

I sometime use path starting with double-backslashes in config file and I don’t have any problem. I always rely on Path.Combine, Path.GetFileName, etc.

In debug, I’m quite sure the path will be shown with doubled backslashes (and \r\n for new lines) but it’s not the string per se but its representation. Is it doubled when you display it with Log Message?

In worst case, you can check if you find four backslashes in your folder path and apply a replace.

folder = folder.Replace("\\", "\")