GetSaveFileName() not returning path of CD burning staging area on XP - windows

I have a feature where I save a file to a location that user specifies. I'm using GetSaveFileName() to show the Save As dialog. I then use the path that it returns to write out the file to that location. I've noticed that it does not work when the user chooses the CD-RW drive on an XP machine. This same process works correctly on Vista and Windows 7. I've made the following observations:
The path returned by GetSaveFileName() returns the path of the temporary staging area when choosing the CD burner root folder (F: in my case) on Win7/Vista.
On XP, choosing the CD burner root folder just returns F:\ as the path. HOWEVER, if I create a sub folder using the Save As dialog and save the file in this folder (e.g. F:\folder), the path is that of the temporary folder.
Using another application such as Notepad in XP will correctly redirect to the temp folder for F:\ .
So the problem only exists when saving to the root folder of the CD burner on XP. How can I achieve the same functionality as Notepad in XP and have Save As redirect to the temp folder so I have have a path I can write to for CreateFile()?

I think the fact that you get back the CD staging area for some paths is a "by-product" of the way the IShellFolder::GetDisplayNameOf function works. I've found that for CD burners, a PIDL for a file or folder that only exists in the staging area, will convert to a string referencing the staging area. A PIDL for a file or folder that exists on the CD (whether or not it exists in the staging area as well) will convert to a string referencing the CD. Because the root folder (by definition) exists on the CD, it's the CD path you get back as a string.
I would suggest handling this yourself. You can use the ICDBurn::GetRecorderDriveLetter function to get the recorder's drive letter - then it's trivial to compare against the string you get back from GetSaveFileName(). If you do get back a path on the CD burner, you can use SHGetFolderLocation with CSIDL_CDBURN_AREA to get the path of the staging area - then it's simply a matter of replacing the drive letter at the beginning of the path string with the path of the staging area.

Related

Accessing the Windows Recycle Bin in WSL2

In WSL2, is it possible to access the Windows Recycling Bin? Say for example you move file.txt into the recycling bin in the Windows GUI, could you move to the directory that file.txt is contained in on the WSL terminal? How could this be done?
Officially, no. A special implementation of IShellFolder in shell32 handles the recycle bin when files are moved/deleted in the shell namespace.
Unofficially, each drive contains a hidden $Recycle.Bin folder (Recycler before Vista). Each user has a directory inside there named after their SID where their deleted files are stored.
The deleted files do not retain their original filenames, only their extension. Before Vista, a file named INFO2 stored this information. These days $I... stores the information for the original files renamed to $R...
Look at forensics tools like Rifiuti2 if you need to understand the internal format so you can extract the original name...

basic mkdir command not working. What am I doing wrong?

So I'm trying to create basic directory and push it out across our end users. I've got the basic .cmd to work but it breaks when I have a folder with multiple spaces.
cmd /c mkdir "C:\ProgramData\Example\This Folder Has Four Spaces\Example"
the plan is to set this to run automatically on machines.. If I remove the path with the long folder name, it works perfectly fine. Is there a way for me to place a file in the directory that has a long folder name with spaces? I wasn't sure if there was any sort of bypass to this. I initially thought it was because I was trying to copy a file to the program data folder but I've tested this with other folder names and it works fine. Just seems to be this specific folder it doesn't work with so I'm led to believe it's because of how long the folder name is.

CMD move files without knowing folder name

I'm using Windows CMD via an ANT Build file to move files from a sub-folder into a parent folder that is three levels up. The structure looks like this:
containingFolder
-tempFolder
-unkownNamedFolder
-contents.xyz
Using linux I can do this with the command mv */*.* .. with the current working directory being the temp folder. I don't know what the unknownNamedFolder will be called, but I do know that it will always be the only folder within the temp folder and that whatever content is within it needs to be extracted out to the containingFolder so that temp can be deleted and only the files will remain.
I've tried a command such as /c move *\*.* .. 2>NUL but this doesn't work.

Is there a way to copy files with a batch file to the folder that batch file is in?

So I am trying to make a batch file to sync an external hard drive.
My hard drive is not always connected to the same letter, so i cannot just make a batch file with xcopy F:\Folder1 G:\backupharddrive because G:\backupharddrivewould be variable
Is there a way to just copy to the folder the batch file is in?
Just use relative addressing, where . represents the current directory.
xcopy F:\Folder1 .
For future reference, you can also access the parent of the current folder (IOW, 1 level higher up in the directory tree) using ... This makes it handy to move up a level, or even over one. For instance, to copy files from C:\Temp\One to C:\Temp\Two, you can use
xcopy *.* ..\Two\
which means copy the files from this folder up one level and then over to the Two folder.
If you use dir from a command prompt, you'll see that in any level below the drive root you'll have items for . and .. in the list. (The root only has ., because it has no parent folder.

Setting a path in OSX for Matlab

I just shifted from a windows machine to a apple machine at work. I have no experience with apple and this is the first time I am using OSX.
I have a matlab script that I have to run on this machine but I cannot seem to get the path to my files.
My files are on a network drive. In windows its as simple as U:\Matlab Now I can access my files in the explorer but cannot seem to set them in Matlab using cd
To get the path of my files I right clicked on the folder and copied the where It provided me with this:
Volumes/home9/MATLAB/
Now to set these paths in Matlab I did this:
cd('Volumes/home9/MATLAB/')
But am provided with the error:
Cannot CD to Volumes/home9/MATLAB/ (Name is nonexistent or not a directory).
As you can tell I have no idea what I am doing. Some guidance would be appreciated.
Thank you
I think you meant to use which, not where. where doesn't exist in MATLAB! Now, your problem is probably due to the fact that you need to prepend your path with /. Therefore, your path should be: /Volumes/home9/MATLAB/. If you don't include the /, it assumes that the directory is local or where MATLAB has currently defined the working directory to be. Judging from the context, you want the absolute path of the directory, and that's why you need the / character as there is a Volumes directory in your root directory.
Try that and see if that works!

Resources