|
Hello, I have a weird problem regarding the deleting of a folder.
I'm trying to delete a folder using this code
TCHAR exeDirectory[MAX_PATH];
GetCurrentDirectory(sizeof(exeDirecotry) - 1, exeDirectory);
CString szStoreFolder;
szStoreFolder.Format(_T("%s\\td10"),exeDirectory);
......
SHFILEOPSTRUCT op;
op.pFrom = szFolderName;
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
op.fAnyOperationsAborted = false;
op.hNameMappings = NULL;
int er= SHFileOperation(&op);
_tprintf(_T("Eroare %d "),er);
The problem is that it doesn't work every time.
It depends on the exeDirectory name and on the folder name (the folder that I'm trying to delete)
For instance if the exeDirectory is TEST and the folder name is Td10 it doesn't work. If the exeDirectory is ZIP_OPTION and the folder name TD10 it works. If the exe folder is TEST and the folder name is TemporaryData it works but now for the ZIP_OPTION folder it dosn't work.
I made a debug and the szFolder contains the correct path.
I've got the error 1026.
I tried to take the path with CFileFinder but still the same problem appears. I tried also to take the short folder name but it the same. I do not know what to do.
Any help or advice would be appreciate
Tnx
|
|
|
|
|
Why are you using GetCurrentDirectory()?
I don't know the rest of your code but there is a chance that the current directory changes after a recursive deletion with SHFileOperation or elsewhere in your code.
Also, you are mentioning 3 different variables for the path: "szStoreFolder", "szFolder" and "szFolderName". Very confusing.
|
|
|
|
|
problem solved
You should use the relative name to the current folder and the short name of the folder DOES NOT WORK WITH LONG FOLDER NAME.
|
|
|
|
|
I think your problem may actually be that your szStoreFolder is terminated only with a single NULL character and it should be terminated with double NULL characters.
MSDN[^]says to use fully qualified path names (not relative) - this allows the files/folders to be moved to the recycle bin.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Maybe that is true. I tried to build the string like there but the code didn't delete the folder.
Anyway I want to permanently delete the folder so it is ok like it is now.
The problem was related with full path and full name of folder that I want to delete (for the folder name you must use the short name not the long one).
Anyway that was a weird problem because in 50%-60% of case the code was working fine, without any changes.
|
|
|
|
|
I have created toolbar and statusbar controls on dialog.
But if i do not call the below function the controls are not appearing.
RepositionBars(......)
I have specified the controls position too..
Please explain.
|
|
|
|
|
How did you make your statusbar?
|
|
|
|
|
Here is the code
static UINT indicators[] =
{
ID_INDICATOR_COORD,
ID_INDICATOR_TIME,
};
.........
.........
m_StatusBar.Create(this);
m_StatusBar.SetIndicators(indicators, 2);
CRect rect;
GetClientRect(&rect);
m_StatusBar.SetPaneInfo(0, ID_INDICATOR_COORD, SBPS_NORMAL, rect.Width() - 100 );
m_StatusBar.SetPaneInfo(1, ID_INDICATOR_TIME, SBPS_STRETCH, 0);
........
..........
|
|
|
|
|
Well use of this code and it works for you 100%.
CStatusBarCtrl m_StatusBar;
CRect rect;
GetClientRect(&rect);
int m_status[2]= {100, 160};
m_StatusBar.Create(WS_CHILD|WS_VISIBLE,rect, this, 0);
m_StatusBar.SetParts(2, m_status);
m_StatusBar.SetText(_T("Oh"),0,0);
m_StatusBar.SetText(_T("RSAK"), 1, 0);
|
|
|
|
|
I need samples for creating toolbar in a dialogs.
link?
|
|
|
|
|
I think I gove you links about make statusbar,right?
|
|
|
|
|
No its given by Cédric Moonen
|
|
|
|
|
No you wrong see here[^] its good example.
|
|
|
|
|
Why would that help him ? The status bar is used in a SDI application, not a dialog application. Furthermore, the only thing it does is displaying text, so how is it related to his problem ?
|
|
|
|
|
Realy I didnt see it I saw that link of my messages.I answered to more a question about statusbar in these days so maybe my address was wrong
|
|
|
|
|
I have added status bar using the link given by you.
Kindly share a link for adding Toolbar in a dialog.
How to display status text if i move cursor over toolbar buttons?
|
|
|
|
|
RSAK wrote: How to display status text if i move cursor over toolbar buttons?
The search function on codeproject hasn't been disabled yet you know. Anyway, here[^] is what I've found after 20 seconds searching.
|
|
|
|
|
Actually the link which you gave for statusbar is simple, clear and easy to do also.
Thats why i requested for toolbar.
|
|
|
|
|
Yes. I was wrong. Its also given by Cédric Moonen.
Ok we are going away from my query...thats about RepositionBars(...)...
|
|
|
|
|
When I'm running an application, I got a Debug error Message(R6034), which says,"An application has made an attempt to load the C Runtime library without using a manifest". I've developed this application using Visual C++ 2008 Express Edition. How do I resolve this error?
modified on Tuesday, June 10, 2008 2:32 AM
|
|
|
|
|
|
In the Manifest tool node If I select Embed Manifest to No, the manifest file is created. But When I ran the application, it shows me an Assertion Failed Error. How do I resolve this error?
|
|
|
|
|
I have created two DLL .One is PracticeDLL_1 and otherone is PracticeDLL_2
PracticeDLL_1 has a function called Calc(int * ,int *)and PracticeDLL_2 has a function called Sub(int * ,int *).I am calling Calc function from
main function and which inturn calling Sub function from DLL but the function sub is not excuting .I have given the path of practiceDLL_1 in Link option in project settings and copied that dll in application folder.still i am not getting desired result. what is the probelm? can anyone help me ?
--------------------------------------------------------------
// CallingFunctionFromDLL.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include "MethodHeader.h"
int main(int argc, char* argv[])
{
int m,n;
m=100;
n=90;
//Sub(&m,&n);
char *t=Calc(&m,&n);
printf("%s \n",t);
printf("%d %d \n",m,n);
return 0;
}
----------------------------------------------
PracticeDLL_1
#include<stdio.h>
#include<conio.h>
#include "DLLHeader.h"
//#include "CodeHeader.h"
extern "C" _declspec(dllexport) char* Calc(int *no1,int *no2)
{
int sum;
char *result="successfull";
//sum = no1 + no2;
Sub(no1,no2);
//printf("%d %d",*no1,*&no2);
return result;
}
-------------------------------------------------------------
PracticeDLL_2
#include<stdio.h>
#include<conio.h>
//#include "CodeHeader.h"
extern "C" _declspec(dllexport) void Sub(int *swe,int *tur)
{
(*swe)--;
(*tur)--;
}
----------------------------------------
any help appreciated .
Thanks in advance.
|
|
|
|
|
Copy .Lib file also in Application folder and give lib name in link don't give whole path.
-@SuDhIrKuMaR@-
|
|
|
|
|
sudhir_Kumar wrote: Copy .Lib file also in Application folder and give lib name in link don't give whole path.
Why would that help ? Your lib file can be located anywhere on your disk, that doesn't make any difference.
|
|
|
|