-
September 14th, 2010, 07:18 AM
#1
getting contents from drive letter
Hi all,
is it possible to get the contents of a drive i.e the list of all files and folders inside the drive ?
i have the drive letter with me.
so please can i get some help to get all the contents inside the drive ???
Thank You
-
September 14th, 2010, 07:28 AM
#2
Re: getting contents from drive letter
Have a look at CFileFind class and its methods.
Victor Nijegorodov
-
September 14th, 2010, 08:06 AM
#3
Re: getting contents from drive letter
if there are any folders in the directory, how would you seek them?
please do have a proper look at the question which says i want to list all the contents of a drive ??
all the members also need a destination ?? without enumerating the contents how would we pass the contents to CFindFIle class?
-
September 14th, 2010, 08:14 AM
#4
Re: getting contents from drive letter
Originally Posted by sgcoders
please do have a proper look at the question which says i want to list all the contents of a drive ??
Please do have a proper look at the documentation of CFileFind class and its methods in MSDN.
And you cannot "pass the contents" "without enumerating".
See the example in CFileFind::IsDirectory
Victor Nijegorodov
-
September 14th, 2010, 08:38 AM
#5
Re: getting contents from drive letter
A quick and dirty method (not necessarily recommended therefore) to get all files and folders of a drive is to using the dir /s command of the Windows command interpreter cmd and redirect the output of that command to a file.
Code:
// assume the drive letter is x
system("dir /s /b x:\*.* > xxx.txt");
std::ifstream xxx("xxx.txt");
if (xxx)
{
std::string line;
while (getline(xxx, line))
std::cout << line << std::endl;
xxx.close();
remove("xxx.txt");
}
-
September 14th, 2010, 10:38 AM
#6
Re: getting contents from drive letter
Originally Posted by itsmeandnobodyelse
A quick and dirty method ...
Clear dirty.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|