Home » Community » Newbie corner » Get volume name of shares ... (Try to get a shares volume name)
Re: Get volume name of shares ... [message #56252 is a reply to message #56222] |
Sun, 14 February 2021 14:21 |
dschoni
Messages: 15 Registered: January 2021 Location: Switzerland
|
Promising Member |
|
|
Dear Mirek
Quote:Nope, you do Find with empty path and then you get it in FileInfo::root_desc.
This works on a fixed disk drive, but not on a network share.
I've tried:
void FolderTree::AddSystemPlaces(int id)
{
Array<FileSystemInfo::FileInfo> root;
FileSystemInfo fs;
#ifdef PLATFORM_WIN32
root = fs.Find("",1000,false);
for(int i = 0; i < root.GetCount(); i++) {
String desc = root[i].root_desc;
String n = root[i].filename;
if(n != "A:\\" && n != "B:\\") {
#ifdef PLATFORM_WIN32
if(*n.Last() == '\\')
n.Trim(n.GetCount() - 1);
#endif
String type;
int maxName;
if(desc.GetCount() == 0) {
GetDriveInformation(n, type, desc, maxName, type);
if (desc == "") desc << " " << t_("Local Disk");
}
desc << " (" << n << ")";
AddPlace(id, GetDriveImage(root[i].root_style), root[i].filename, desc);
}
}
if(GetSystemMetrics(SM_REMOTESESSION))
for(int drive = 'A'; drive < 'Z'; drive++) {
String path = Format("\\\\tsclient\\%c", drive);
if(FindFile(path + "\\*.*"))
AddPlace(id, path, Format(t_("%c on client"), drive));
}
#endif
#ifdef PLATFORM_POSIX
root = fs.Find("/media/*",1000,false);
for(int i = 0; i < root.GetCount(); i++) {
String fn = root[i].filename;
if(*fn != '.' && fn.Find("floppy") < 0)
AddPlace(id, "/media/" + fn, fn);
}
AddPlace(id, "/", t_("Computer"));
#endif
}
After
String desc = root[i].root_desc;
String n = root[i].filename;
"desc" contains the value "Document" at my fixed disk drive "D:" which is the volume name.
"n" contains "D:\\".
If I go further to "M:", which is a network share and the volume name is "Media", i've got:
"desc" contains "".
"n" contains "M:\\".
This is why I've copied "GetDriveInformation" from the SysInfo-package to my code and used Quote:
GetDriveInformation(n, type, desc, maxName, type); if "desc" is empty.
After "GetDriveInformation" "desc" contains "Media".
Best Regards, Daniel
|
|
|
|
|
Get volume name of shares ...
By: dschoni on Mon, 08 February 2021 22:11
|
|
|
Re: Get volume name of shares ...
By: dschoni on Mon, 08 February 2021 22:31
|
|
|
Re: Get volume name of shares ...
By: dschoni on Mon, 08 February 2021 23:18
|
|
|
Re: Get volume name of shares ...
By: koldo on Tue, 09 February 2021 22:00
|
|
|
Re: Get volume name of shares ...
By: dschoni on Wed, 10 February 2021 16:44
|
|
|
Re: Get volume name of shares ...
By: koldo on Wed, 10 February 2021 20:33
|
|
|
Re: Get volume name of shares ...
By: koldo on Thu, 11 February 2021 08:39
|
|
|
Re: Get volume name of shares ...
By: dschoni on Sun, 14 February 2021 13:52
|
|
|
Re: Get volume name of shares ...
By: koldo on Mon, 15 February 2021 08:18
|
|
|
Re: Get volume name of shares ...
By: mirek on Mon, 15 February 2021 11:21
|
|
|
Re: Get volume name of shares ...
By: mirek on Wed, 10 February 2021 15:22
|
|
|
Re: Get volume name of shares ...
By: dschoni on Wed, 10 February 2021 18:08
|
|
|
Re: Get volume name of shares ...
By: mirek on Wed, 10 February 2021 21:01
|
|
|
Re: Get volume name of shares ...
By: dschoni on Sun, 14 February 2021 14:21
|
Goto Forum:
Current Time: Thu May 09 23:40:31 CEST 2024
Total time taken to generate the page: 0.02049 seconds
|