Unsolved Can not open file With QFile Class.
-
to add to @mrjj if you want to use those paths without duplicating or reversing the slashes you can use raw strings:
QFile file(R"(\nas\files\gauravFolder:GauravData:$DATA)" );
-
@Gaurav-Badgujar You should not use : in paths/file names especially on Windows
-
@jsulm
but its working on "D:\TestFoldler:GauravData:$DATA"
but this is not working with "\nas\files\gauravFolder:GauravData:$DATA" path. -
@Gaurav-Badgujar As others said you should either use
\\
or / -
@jsulm used "/" as per above mention comment but still not getting any resolution.
-
@Gaurav-Badgujar
Hi
Try to use a full path and see it it works for you.
"c:/nas/files/gauravFolder:GauravData:$DATA"
else
"./nas/files/gauravFolder:GauravData:$DATA"
Its just path issue, i think.Also again, if on window, the ":" is FORBIDDEN
-
@Gaurav-Badgujar What about
\\
? What exact error do you get (http://doc.qt.io/qt-5/qiodevice.html#errorString)?
And why do you use characters like : and $ ? You should avoid such characters in paths and file names. Especially :
: has a special meaning on Windows. Try to save a file in any Windows program using file name with : You will see it does not work. -
Another option, given the name of the first folder is nas i can guess it's a network path, they normally start with 2 slashes, not just 1
-
Hi,
the file names with ":" hide data using ADS (alternate data streams). Strings like ":$DATA" have a special meaning. Normal Explorer and DIR command etc. do not see these files.So I doubt Qt can open them for reading/writing; native CreateFile should be able to do so.
On the other hand: make sure that the file "c:/nas/files/gauravFolder" already exist when you create the data stream file! Here is some code: https://support.microsoft.com/en-us/kb/105763
-Michael. -
@Gaurav-Badgujar ...
There are several things wrong with the path but the :$DATA is the biggest hurdle. It is just not allowed on any M$ operating system. Fixing non-existant paths will be easy but if your file name has special meaning then that could be a problem. Now, if the :$DATA represents some bit of data to write into the file name than ok.
The article "Illegal Characters on Various Operating Systems" explains what is legal on most OSes.
https://kb.acronis.com/content/39790 -
@VRonin yes its network path..typo mistake. and it contains two slashes.
-
:$DATA its not a path we append this string with path.