HELP!! Library for deleting file not there!

S

smp9737

Hello.

I'm developing a Win32 Console Application for a Smart Device (MotoQ).

All i need to do is delete a file with a known name and path. I'm
under the impression that I have to use File::Delete( path ) based on
what MSDN is telling me. Thus I need to include mscorlib.dll ... I
#using this and the method cannot be found. I have tried almost
everything and am completely confused.


#using <C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll>

using namespace System;
using namespace System::IO;
#include "stdafx.h"

#include <Tlhelp32.h>
#include <windows.h>
#include <commctrl.h>
void installCab(LPTSTR cabFile);
void installCabs(LPCTSTR directory);
bool checkIfWCELOADIsRunning();
void removeInstallFiles();

void removeInstallFiles()
{
Delete(" ");
}

ERRORS:::

Error 1 error C3861: 'Delete': identifier not found Installer.cpp 64


ANY IDEAS?!?!

thanks, smp
 
C

Carl Daniel [VC++ MVP]

Hello.

I'm developing a Win32 Console Application for a Smart Device (MotoQ).

All i need to do is delete a file with a known name and path. I'm
under the impression that I have to use File::Delete( path ) based on
what MSDN is telling me. Thus I need to include mscorlib.dll ... I
#using this and the method cannot be found. I have tried almost
everything and am completely confused.

It looks like you might be mixing managed and unmanaged code in an odd way.

If you're doing Managed code, then you would want call
System::IO::File::Delete, but you're trying to call ::Delete, which doesn't
exist. Given the using directives that you have in force, File::Delete
should be a sufficiently qualified name.

If, on the other hand, you're writing pure native code, just call the
::DeleteFile function from the Win32 API and forget about using the CLR
function to do it.

For that matter, since you're writing in C++, you can simply use
::DeleteFile no matter what - the compiler will "do the right thing" to make
it work from managed or native code.

-cd
 
S

smp9737

It looks like you might be mixing managed and unmanaged code in an odd way.

If you're doing Managed code, then you would want call
System::IO::File::Delete, but you're trying to call ::Delete, which doesn't
exist. Given the using directives that you have in force, File::Delete
should be a sufficiently qualified name.

If, on the other hand, you're writing pure native code, just call the
::DeleteFile function from the Win32 API and forget about using the CLR
function to do it.

For that matter, since you're writing in C++, you can simply use
::DeleteFile no matter what - the compiler will "do the right thing" to make
it work from managed or native code.

-cd

Awesome, that seemed to have worked :):DeleteFile)
 
B

Ben Voigt [C++ MVP]

Carl Daniel said:
It looks like you might be mixing managed and unmanaged code in an odd
way.

If you're doing Managed code, then you would want call
System::IO::File::Delete, but you're trying to call ::Delete, which
doesn't exist. Given the using directives that you have in force,
File::Delete should be a sufficiently qualified name.

If, on the other hand, you're writing pure native code, just call the
::DeleteFile function from the Win32 API and forget about using the CLR
function to do it.

For that matter, since you're writing in C++, you can simply use
::DeleteFile no matter what - the compiler will "do the right thing" to
make it work from managed or native code.

I was under the impression that Smart Device runtime can't do C++ interop
(aka It Just Works), so you need to stick with either purely managed code or
purely unmanaged code, and can't use ::DeleteFile Win32 API function from a
managed assembly (at least, you'd need DllImport attribute and use
p/invoke).
 
C

Carl Daniel [VC++ MVP]

Ben said:
I was under the impression that Smart Device runtime can't do C++
interop (aka It Just Works),

I believe you're right - I missed the Smart Device part of the question when
I replied. Mea culpa!

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top