Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Folders
#1
Hey guys, im still a beginner and was wondering how I could create a program that creates an amount of files that the user inputs then creates the files at a directory that the user has chosen

I have successfully created a folder in the project folder but thats about it.

Thanks.

Found this and tried it on a win32 app but it didnt work

Code:
#using <mscorlib.dll>

using namespace System;
using namespace System::IO;

int main() {
    // Specify the directory you want to manipulate.
    String* path = S"c:\\Users\\Faizal";

    try {
        // Determine whether the directory exists.
        if (Directory::Exists(path)) {
            Console::WriteLine(S"That path exists already.");
            return 0;
        }

        // Try to create the directory.
        DirectoryInfo* di = Directory::CreateDirectory(path);
        Console::WriteLine(S"The directory was created successfully at {0}.",
             __box(Directory::GetCreationTime(path)));

        // Delete the directory.
        di->Delete();
        Console::WriteLine(S"The directory was deleted successfully.");
    } catch (Exception* e) {
        Console::WriteLine(S"The process failed: {0}", e);
    }
}
Reply

#2
1st allow me to say that the language you are using is a dead language, MC++ was superseeded by C++/CLI over 5 years ago. I wouldn't even touch MC++ with your dick. Please read here - http://en.wikipedia.org/wiki/C%2B%2B/CLI now that you are using the right language you would want to do something like this,

Code:
array<String^>^ Locations = gcnew array<String^>{ "C:\\1", "C:\\2", "C:\\3" };

for each( String^ s in Locations )
{
      if( !Directory::Exists( s ) )
       {
            //Do Stuff
       }
}

Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.