String *drive, *path;
TreeNode *tn = treeView1->SelectedNode;
drive = tn->Text;
if(drive->get_Length() > 3)
{
MessageBox::Show(drive,S"Invalid Path for Defrag: ");
}
else
{
path = String::Concat(S"defrag ",drive);
system(path);
}
This is the code that doesn't work. Just get a conversion error "error C2664: 'system' : cannot convert parameter 1 from 'System::String __gc *' to 'const char *'"
So I've tried this
String *drive, *path;
Encoding * ascii = Encoding::ASCII;
Encoding * unicode = Encoding::Unicode;
Char new_path[];
TreeNode *tn = treeView1->SelectedNode;
drive = tn->Text;
if(drive->get_Length() > 3)
{
MessageBox::Show(drive,S"Invalid Path for Defrag: ");
}
else
{
path = String::Concat(S"defrag ",drive);
Byte unicodeBytes[] = unicode -> GetBytes(path);
Byte asciiBytes[] = Encoding::Convert(unicode, ascii, unicodeBytes);
Char asciiChars[] = new Char[ascii -> GetCharCount(asciiBytes, 0, asciiBytes -> Length)];
ascii -> GetChars(asciiBytes, 0, asciiBytes->Length, asciiChars, 0);
system(asciiChars);
}
That doesn't work either. "error C2664: 'system' : cannot convert parameter 1 from '__wchar_t __gc[]' to 'const char *'"
I've tried receiveing a __wchar_t array as well, but get a similar error about converting that to a const char *. Tried doing a reinterpret_cast and any other cast you can think of and nothing works.
Is there another function that does the same thing as system() that takes a String?