|
Post by milfredo on Jun 30, 2020 19:31:01 GMT -5
I know how to save a file and put it in a folder on the C drive. But how do I get it to showup on the desktop?
Thanks
|
|
|
Post by BeeTrap on Jun 30, 2020 22:36:17 GMT -5
Just send the file to "C:\Users\xxx\Desktop" folder, where "xxx" is your username or the username that is the target.
|
|
|
Post by milfredo on Jul 1, 2020 0:25:38 GMT -5
Thank you so much. I will give it a shot.
|
|
|
Post by milfredo on Jul 1, 2020 0:37:11 GMT -5
This is what I have. name "C:\Handifast2020\Handi.csv" as "C:\users\Milford\Desktop" + Name2$ + ".csv"
and the file shows up in the desktop file structure. But the file doesn't show up on my desktop screen. Any ideas how I get that to happen?
|
|
|
Post by Chris Iverson on Jul 1, 2020 1:05:55 GMT -5
It's possible you're accidentally generating the wrong path.
The path C:\Users\<username>\Desktop is indeed the default path, but that doesn't mean it is the actual path. It can actually be moved, and the actual name of the folder can change depending on the Windows version or language.
There's an API call you can use to get the actual location, without needing to resolve the above mentioned issues.
CSIDL.DESKTOPDIRECTORY = 16 desktopPath$ = GetSpecialFolder$(CSIDL.DESKTOPDIRECTORY) print desktopPath$
testFile$ = desktopPath$ + "\test.txt"
open testFile$ for output as #file print #file, "test" close #file end
Function GetSpecialFolder$(CSIDL) var$ = space$(_MAX_PATH)
CallDLL #shell32, "SHGetFolderPathA",_ 0 as ulong,_ 'HWND, value is reserved CSIDL as long,_ 'CSIDL_ value 0 as ulong,_ 'hToken, blank for 'check current token' 0 as ulong,_ 'dwFlags, 0 for 'get current path'(SHGFP_TYPE_CURRENT) var$ as ptr,_ ret as long
GetSpecialFolder$ = trim$(var$) End Function
On my computer, that prints E:\Chris\Desktop, because I have moved most of my profile folders to a different folder(and drive!) for convenience reasons.
On most computers, it will print C:\Users\<name>\Desktop.
EDIT: Also, I think you left out the backslash for the Desktop folder separator. If name2$ = "file", then you didn't create C:\Users\milfredo\Desktop\file.csv, you created C:\Users\milfredo\Desktopfile.csv.
|
|
|
Post by milfredo on Jul 1, 2020 2:06:01 GMT -5
Thank you Chris.
This is how final code looks...testFile$ = desktopPath$ +"\" + Name2$ + ".csv
I added the "\" and it works perfectly.
Thanks again for the help.
|
|
|
Post by Rod on Jul 1, 2020 2:09:08 GMT -5
We have said in the past that if you are having trouble with files or paths PRINT the filepath you are creating. Then it is easy to see your mistake.
|
|
|
Post by milfredo on Jul 1, 2020 2:37:41 GMT -5
Thank you Rod.
|
|