I am writing an simple application that will delete a file/directory. The application recives the target file as an argument. I have also put a shortcut in the W Explorer contextual menu, via Shell registry subkey of the folder entry in the HKEY_CLASSES_ROOT. [HKEY_CLASSES_ROOT\Folder\shell\NewMenuOption] @="Wipe it ..." [HKEY_CLASSES_ROOT\Folder\shell\NewMenuOption\command] @="D:\\FileWiper\\bin\\Debug\\FileWiper.exe \"%1\"" If a launch the program from a shell with an filename/folder as an argument it does it's job. But if the program is launched via the option in the Explorer menu and the selected targer is a folder (with a simple file it works), then the deleting fails with the exception " ... file being used by another process". It seems that the program keeps an open handle on the directory. The delete operation is made via Directory.Delete() ( tried also working with DirectoryInfo ...same result). Any one has any idea how can I get past this ? ------------------------------------------------------------------ LATER EDIT : I managed to track the problem after all. Simple stuff really, but forgot about it. Windows set the current directory for the program was set to be the target directory, so a simple change of the current directory was enough to get the program going. -- modified at 4:04 Friday 9th March, 2007
Radu Sorin
Posts
-
Why the open file handle ? [modified] -
Delete DirectoryI have a problem deleting a directory, when that directory is already open by another application (like WExplorer, or TCommander). I get the well known exception ".. the process cannot access the file because is used by another application". How can I get around this ? (TCommander as far as I've seen can delete a dir, even if the dir is open by explorer, so something can be done...). Thanks in advance to all that may give me some info on this problem.
-
Windows RClick menu.How can I add an option to the r-click menu from Windows Explorer ? Can someone help me with some info or a source-code ?
-
how to secure erase/wipe a file ?I want to make a secure erase file tool using c#. I know that there are some rules to be followed when making such a tool(overwriting the file many times,renaming, truncating and than deleting), but i didn't manage to find a document or some site where all this is explained (all i found so far are tons of programs that offer me secure delete solutions, and some well written but old linux document on this matter ... from 96 till now thing have changed a bit ...). Can any of you offer me some recent documentation, or pointers on this ? Thanks. If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. -Gerald Weinberg
-
Working with MS ExcelI need to generate some reports in XLS format and I want to code something in C# that will allow me to manipulate the files. I have seen some basic read/write solutions on this site. I am interested on how i can change the color of a specified cell int the spreadsheet or merge a few cells . Any help or link is greatly appreciated.
-
How to figure out what is root folder of my program at start up? [modified]kinda' late but maybe it will help ... Application.StartupPath
-
CListCtrl Please Help !look here
-
Setting sock Internet Explorer proxy ?So I found out how to set a proxy for Internet Explorer. It's documented here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/setting\_and\_retrieving\_internet\_options.asp My problem is the following . Using the above mechanism allows me to set the proxy for all the protocols. I want to set ( programaticaly )different proxy values for different protocols( ex. one value for http, https and another for sock ). How can i make this?
-
Error tracing problemI have an application that uses COM+ and on some machines i get crashes ... The only error message is the standard windows error message and it gives me this Faulting application application.exe, version 1.0.0.1, faulting module ole32.dll, version 5.1.2600.2726, fault address 0x00120f57. Is there any way in which i can trace this address to a exported function in the ole32.dll to get an ideea what exported function is crashing? Thanks .
-
RichTextBox Selection color problemAs short as i can explain... I have a RichTextBox that i want to use for syntax highlighting. For coloring i use: richControl.Select(...); richControl.SelectionColor= ...; and it works . The text is highlighted using a list of keywords. Lets say that I have te following line in my textbox: I like icecream In this line "like" is a keyword and its color is red(for explanation sake) and all the other words are black. THE PROBLEM is that if I move the caret just after the word "like" and I start typing, the new inputed characters will also be red,and i wanted them to be black. How can i escape this problem?
-
RichTextBoxControl cursor positionHow can i change programaticaly the position of the caret in a RichTextBoxControl ?
-
Configuration problem ...just now ... thanks
-
Configuration problem ...I am working on an MFC project. I added some COM capabilities, built the Debug version. All worked well. When i tryed to switch to the Release build i got this error(first from list ... there were several others derived from it) error C2065: '_AtlModule' : undeclared identifier I think is a configuration derived error, but I'm not sure. Does anyone has any ideea about how to solve it ?
-
ATL property problemI am using VC2003 and working on a mfc project that includes ALT(i'm a beginer in ATL) and I encountered the folowing problem : I have defined some properties interface IATLDisplay : IDispatch{ // ..... more properties // the next line is the one with the problem [propget, id(2), helpstring("property GetLastChangeTime")] HRESULT GetLastChangeTime([out, retval] COleDateTime* pVal); }; Upon compiling i get the folowing error message : error MIDL2025 : syntax error : expecting a type specification near "COleDateTime" - error related to the above presented line Any ideea why this apears ? do i need to import some aditional .idl file ? Thanks for any help .
-
parent and child data exchangeput two pointers in the child dialog class, that will poin to xParent, yParent (lets say pXParent,pYParent).. Before calling the child dialog initialize them with the address of the xParent, yParent something like childDlg.pXParent = &xParent; childDlg.pYParent = &yParent; childDlg.DoModal(); In childDlg class in the onSet(or whatever name you have for the pushing of the Set button) out something like this *pXParent = xChild; *pYParent = yChild; .... now the xParent,yParent will have the values of xChild, yChild
-
Important: Am I running under user or administrator?BOOL IsUserAdmin(VOID) /*++ Routine Description: This routine returns TRUE if the caller's process is a member of the Administrators local group. Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token. Arguments: None. Return Value: TRUE - Caller has Administrators local group. FALSE - Caller does not have Administrators local group. -- */ { BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; b = AllocateAndInitializeSid( &NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if(b) { if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } return(b); } Taken from MSDN
-
Important: Am I running under user or administrator?How can i programatically see from my program if it is running under a normal limited account, or under an administrator account under Windows? I need to see from inside the program if it been started by a user or by an admin ... :confused: -- modified at 4:26 Tuesday 18th April, 2006
-
Automatization help neededI am working on a mfc application. At the time the project started no automatization support was defined for it from the wizard application. Now i want to add some automatization features . Can any one help me on this matter? Do i need to recode the whole prject ?
-
IP to name in LANIf i have the IP of a LAN computer how can i get programaticaly retrive the pc's name( the name asociated with the ip) ?
-
IP range. Help NeededI want to compare a IP against an IP range. I want to know how to implement this, involving also the mask for each IP. Ex: The range is [IPa->MaskA....IPb->MaskB], and i want to know if IPx->MaskX is in interval.