Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / August 2007

Tip: Looking for answers? Try searching our database.

HELP!! Library for deleting file not there!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smp9737@gmail.com - 31 Jul 2007 14:43 GMT
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
Carl Daniel [VC++ MVP] - 31 Jul 2007 15:02 GMT
> Hello.
>
[quoted text clipped - 5 lines]
> #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
smp9737@gmail.com - 31 Jul 2007 15:13 GMT
On Jul 31, 10:02 am, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospam> wrote:
> smp9...@gmail.com wrote:
> > Hello.
[quoted text clipped - 23 lines]
>
> -cd

Awesome, that seemed to have worked (::DeleteFile)
Ben Voigt [C++ MVP] - 03 Aug 2007 20:43 GMT
>> Hello.
>>
[quoted text clipped - 21 lines]
> ::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).

> -cd
Carl Daniel [VC++ MVP] - 07 Aug 2007 16:47 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.