Using Visual C++ 2010 Express here under XP Pro SP3. I've been using VBA for Access for several years and have done a few apps for myself in Visual Basic. I've been trying to get a better handle on C++. While I've been through some tutorials in C++, I'm really trying to grasp how to use some of the .NET-specific items, including ones I've used in VB with little or no problem. So I have been trying to essentially re-write some small programs that I've done in VB into C++ as an exercise.
The MSDN article on the DeleteFile method has examples for VB, but not for any other language. (ms127977)
In VB, this is accomplished by using the
at the start of the program. So in my C++ program I have
- #include "stdafx.h"
-
#include <string>
-
using namespace System;
-
using namespace System::IO;
-
using namespace System::Collections;
-
The key thing here being that System::IO, I'm thinking. The command I have in VB is:
- Dim logfile2 As String
-
logfile2 = "\\Sharename\\directory\\filename.ext"
-
My.Computer.FileSystem.DeleteFile(logfile2)
So I tried:
-
String^ logfile2 = "\\\\Sharename\\directory\\filename.ext"
-
My::Computer::FileSystem::DeleteFile(logfile2);
but that gives me "'My' : is not a class or namespace name." However, when I try it as...
I get "'DeleteFile' : identifier not found." I think that would be expected, except that since I thought I was specifying the "using namespace System::IO;" I was telling where to look for that. I'm clearly missing some key parts of the namespace specification to refer to this feature of .NET in C++, and I'm wondering if I should use C++'s remove() here. Of course, my goal is to use the same .NET features I used in my VB application simply re-written for C++.
I don't necessarily want the code. I want to understand what key piece I'm missing in understanding here.