473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

DeleteFile in Visual C++ (coming from VB)

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

Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
at the start of the program. So in my C++ program I have

Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include <string>
  3. using namespace System;
  4. using namespace System::IO;
  5. using namespace System::Collections;
  6.  
The key thing here being that System::IO, I'm thinking. The command I have in VB is:

Expand|Select|Wrap|Line Numbers
  1. Dim logfile2 As String
  2. logfile2 = "\\Sharename\\directory\\filename.ext"
  3. My.Computer.FileSystem.DeleteFile(logfile2)
So I tried:
Expand|Select|Wrap|Line Numbers
  1. String^ logfile2 = "\\\\Sharename\\directory\\filename.ext"
  2. My::Computer::FileSystem::DeleteFile(logfile2);
but that gives me "'My' : is not a class or namespace name." However, when I try it as...

Expand|Select|Wrap|Line Numbers
  1. DeleteFile(logfile2);
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.
Oct 22 '13 #1
0 1520

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tom Bates | last post by:
I can successfully delete files using fso.DeleteFile when in an ASP script. But in Session_OnEnd, where I'd *really* like to clean up files, it appears that DeleteFile doesn't work. I've tried...
11
by: andrea azzini | last post by:
I've got an ASP3 (IIS6) site, in which some scripts need to generate temporary files in order to work. Now, the fact is: I would like those temporary files to be deleted when a user's session ends...
4
by: Jason Shohet | last post by:
I'm using Visual Studio, with ASP.NET. Is VSS on a separate CD. Also, is it possible to use the VSS beta (2005) with .NET if I'm not using the .NET beta. And finally, where do I get the VSS...
4
by: rbt | last post by:
Can someone detail the differences between these two? On Windows which is preferred? Also, is it true that win32api.DeleteFile() can remove the 'special' files located in the 'special' folders...
5
by: Just call me James | last post by:
Hi, Coming away from the luxury of the delphi IDE has been something of a shock. As a consequence I've become aware that maybe I need to spend some money on a python IDE. As a beginner I...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
8
by: king kikapu | last post by:
Hi to all, i am not sure if this question really belongs here but anyway, here it goes: I have seen a lot of IDEs for Python, a lot of good stuff but actually none of them has what, for example,...
1
by: Liucy | last post by:
Dear all, I encounter a problem about DeleteFile() with ANSI stdio functions. It always fails to delete file and sets ERROR_SHARING_VIOLATION. I know I can use remove() instead of DeleteFile(),...
3
by: Johnson | last post by:
I'm not sure if this is an IIS 5.1 issue or ASP.NET issue, or Visual Studio 2008 issue -- thus posting to 3 groups. Please don't be offended. The problem I'm encountering is that Visual Studio...
7
by: Parul Vinod | last post by:
I am using Visual Studio 2008; I am executing one query and its results are coming in the datareader dr1; I have checked this in debug window. Even though values are coming inside datareader it's...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.