|
Create a blank workspace with no files added to it.
Use the Project>Add To Project>Files and drop the files that you were using earlier. That's all
|
|
|
|
|
Select the Add to Project option from the Project menu. Select New. Click the Projects tab. Add your new project here. Rather than adding more files to a single project and workspace, this will create separate projects within the same workspace.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I delete all the files/directories in a directory recursively in my application, and since that takes time I want to show a progress bar.
To implement the progress bar I first need to scan the directory to know how many files are there and then in the second pass I progress the bar appropriately every time I delete a file/directory.
Is there a way to quickly find out how many files, including those in the sub directories, are there in a directory? If there is a way other than explicitly walking down the directory using FindFirstFile/FindNextFile, I would like to know, since this is causing the time to delete almost 1.5 times the time spent.
thanks!
|
|
|
|
|
There is no need to make two passes. While counting, add the list of files and folders to an array of some sort and delete them from there.
You can always use SHFileOperation() . It uses recursion and a progress bar.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Hi
pls send your mail id to dingudikka@yahoo.com
I will send the sample source code to count the no:of files and folders in a drive
regards
Vallikumar A
|
|
|
|
|
hi guys,
we have a game server/written in c++/ and an application/written in erlang/ simulating thousand of users playing on the game server.
The server manages connections using IO Completion ports, but when launching many/thousands connections/ against the server it starts dropping connections - the erlang application reports that the socket is closed, while trying to write to the socket.
How can I get the reason for closing the socket on the server side - with GetLastError function i'm getting just the error code of the io operation attempt on the socket. But I need the error for socket closure, please help!
All ideas are welcomed,
Thanks
yani
|
|
|
|
|
socket closure causes
1. completion of a queued read operation with 0 bytes(gracefull close) and this is no error.
or/and 2. GetQueuedCompletionStatus returns false. now GetLastError returns the error of the queued operation.
U gotta mungle with the OS's settings to allow more sockets and give WSAAccept/accept a big queue.
|
|
|
|
|
Hi,
I am making an asynchronous ftp connection and then I want to list all files in the current directory. Here is my function
BOOL
StatupController::StartupSyncSoftware( StationType _stType ) {
ClsArchive *UnZipper;
char pszZipFile[64];
char pszDestPath[64];
char pszRemoteFile[64];
char pszFtpServerAddress[64];
HINTERNET hConnection =NULL,
hFtpConnection =NULL,
hDir =NULL;
BOOL bResult;
HINSTANCE hOcx;
FARPROC lpfn;
WIN32_FIND_DATA Data;
BOOL bRes;
DWORD error;
UnZipper = new ClsArchive();
switch( _stType ) {
case SatelliteStation:
strcpy( pszZipFile, "C:\\Flightvision.zip" );
strcpy( pszDestPath, "C:\\" );
strcpy( pszRemoteFile, "Flightvision.zip" );
strcpy( pszFtpServerAddress, "192.168.1.38" );
// open ftp connection
hConnection = InternetOpen( "FVStartup", INTERNET_OPEN_TYPE_DIRECT,
NULL, NULL, INTERNET_FLAG_ASYNC );
InternetSetStatusCallback(hConnection,FtpCallback);
if( hConnection == NULL ) return FALSE;
hFtpConnection = InternetConnect( hConnection, pszFtpServerAddress, INTERNET_DEFAULT_FTP_PORT,
"anonymous", "pass", INTERNET_SERVICE_FTP, 0, 0 );
if(hFtpConnection == NULL) return FALSE;
// find latest version
//DisplayDir(hFtpConnection,INTERNET_FLAG_NEED_FILE);
hDir = FtpFindFirstFile(hFtpConnection, TEXT ("*.*"),
&Data,
INTERNET_FLAG_NEED_FILE,
0);
if(hDir!=NULL) {
do {
bRes = InternetFindNextFile(hDir,&Data);
} while((error=GetLastError())!=ERROR_NO_MORE_FILES); // ERROR_IO_PENDING 997
}
// close connection
InternetCloseHandle(hDir);
InternetCloseHandle(hFtpConnection);
InternetCloseHandle(hConnection);
case BaseStation:
case WorkStation:
case NotAssigned:
default:
return false;
}
the problem is that the InternetFindNextFile(..) function always returns FALSE and the last error that I gen with GetLastError() is ERROR_IO_PENDING. I did not start any lengthy operation before that, this is way it doesn't make much sence to me. I also noticed that the FtpCallback function is never called and, of course, I think this is OK since no operation has been started yet. Can somebody give more insight on this and help me figure out why the directory listing isn't working correctly?
Thank you very much in advance.
A. Kafazov
|
|
|
|
|
akafazov wrote: the problem is that the InternetFindNextFile(..) function always returns FALSE and the last error that I gen with GetLastError() is ERROR_IO_PENDING.
Which indicates that the request has been made asynchronously, and your application will be called back with INTERNET_STATUS_REQUEST_COMPLETE when the function has completed.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
However, the callback function is never called with INTERNET_STATUS_REQUEST_COMPLETE or any other flag. The situation also indicates that there is an outstanding operation in progress but there isn't. It's all very weird and I don't understand why.
A. Kafazov
|
|
|
|
|
I am using NetShareGetInfo and i am getting a NERR_NetNameNotFound.I am using the folder path as the share name e.g "C:\\WINNT\\profiles\\chikomok\\My Documents\\Open_Shares" and the sever is the remote P.C were the program is running
Can some please tell me what the problem could be.
Kelvin Chikomo
|
|
|
|
|
If the share name does not exist, then system will return NERR_NetNameNotFound error message. So please check your share name exactly with the shared device in the server.
And also server name should begins with \\. If this parameter is NULL, the local computer is used.
best of luck
regards
Vallikumar A
|
|
|
|
|
When i try to use \\. i get an error 53 which i do not know what it means.
Any help
Here is my code
<br />
#include "stdafx.h"<br />
#include "test2.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
CWinApp theApp;<br />
<br />
using namespace std;<br />
<br />
<br />
void wmain( int argc, TCHAR *lpszArgv[ ])<br />
{<br />
PSHARE_INFO_502 BufPtr;<br />
NET_API_STATUS res;<br />
LPTSTR lpszServer = NULL, lpszShare;<br />
switch(argc)<br />
{<br />
case 3:<br />
lpszServer = lpszArgv[2];<br />
case 2:<br />
lpszShare = lpszArgv[1];<br />
break;<br />
default:<br />
printf("Usage: NetShareGetInfo sharename <servername>\n");<br />
return;<br />
}<br />
cout<<lpszServer<<" "<<lpszShare<<endl;<br />
if((res = NetShareGetInfo ("\\.","guest" ,502,(LPBYTE *) &BufPtr)) == ERROR_SUCCESS)<br />
{<br />
printf("%S\t%S\t%u\n",BufPtr->shi502_netname, BufPtr->shi502_path, BufPtr->shi502_current_uses);<br />
if (IsValidSecurityDescriptor(BufPtr->shi502_security_descriptor))<br />
printf("It has a valid Security Descriptor.\n");<br />
else<br />
printf("It does not have a valid Security Descriptor.\n");<br />
NetApiBufferFree(BufPtr); <br />
}<br />
else <br />
{<br />
<br />
if(res == NERR_NetNameNotFound)<br />
cout<<"Netnamenotfound"<<endl;<br />
else if(res==ERROR_ACCESS_DENIED)<br />
cout<<"Access denied"<<endl;<br />
else if(res==ERROR_INVALID_LEVEL)<br />
cout<<"invalid level"<<endl;<br />
else if(res==ERROR_INVALID_PARAMETER)<br />
cout<<"invalid parameter"<<endl;<br />
else if(res==ERROR_MORE_DATA)<br />
cout<<"More data"<<endl;<br />
else if(res==ERROR_NOT_ENOUGH_MEMORY)<br />
cout<<"not enough memory"<<endl;<br />
else if(res==NERR_BufTooSmall)<br />
cout<<"buffer too small"<<endl;<br />
else<br />
cout<<"Error "<<res<<endl;<br />
}<br />
return;<br />
}
|
|
|
|
|
You didn't specify that to which machine have you connected to, so it is throwing that error.
Use NetResource structure and WNetAddConnection to open the connection so that you can have access to the shared folders on the remote machine . You can also try and check other return values.
Remember WNetAddConnection returns a DWORD value
eg ERROR_ACCESS_DENIED etc.
Does this solve your problem
Wishes
Anshuman
|
|
|
|
|
I thought all i had to do was to call the netsharegetinfo method. i am just trying to get information from my computer thats all. The method description says put //. to access shares on the remote machine.
I really need to get this going
Help please
Kelvin Chikomo
|
|
|
|
|
If you want to access the information from your machine then no need to give the share name(Server) with \\.
Instead this give NULL.
This will get the information from your local machine.
regards
Vallikumar A
|
|
|
|
|
I have tried that, thats when i get the NERR_NetNameNotFound error. should i give the full path of my shared folder or just the share name. It seems logical to use the share name.
|
|
|
|
|
The NetShareGetInfo function retrieves information about a particular shared resource on a server.??To what extent do you want to have the control??.
SO if you need the control of the files/folders/printers that are residing on the other machine use NETRESOURCE structure and pass it to WNetAddConnection2 function. This opens the connection and you can get the control to the shared folders.
Can you tell me what exactly do you want to do because there are a lot of roads that lead to somewhere from here but that would be useless mentioning here if they are of no use to you
Wishes
Anshuman
|
|
|
|
|
I am creating a tool to check the attributes of all the shares on my computer. just my computer. So basically i need to get all the information about the shares on my PC using NetShareGetInfo.
So far i have been trying to get info for one specific share but it keeps saying the the shre does not exist(NERR_NetNameNotFound)
Thanks for the help hey.
Kelvin Chikomo
|
|
|
|
|
kelprinc wrote: So basically i need to get all the information about the shares on my PC using NetShareGetInfo.
Use NetShareEnum(NULL, ...) instead. If you need information about a particular share, use NetShareGetInfo(NULL, _T("NameOfShare"), ...) .
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Hi
I have an Windows Explorer type MFC SDI Application.
In my application i am doing heavy processing using worker threads so that the main thread donot hangs(during a heavy process) & keeps processing user requests.
Now at the time the heavy process(finding files/folders in logical drive) is executing, the GUI is also being updated via ::SendMessage() function from worker thread to the primary thread.
Following are updated:
--> In tree view folders are added.
--> In List View files are added in Report view.
--> Progress bar status bar pane 0 is updated.
--> Status bar pane 1 is also updated with total of files & folders.
Now my question is:
Q1--> Is the above strategy fine?.
Also while the heavy process is running & the user presses the <stop> toolbar button, the control goes to CMainFrm::OnStop(). From this function a message box is prompted to the user asking whether he wants to stop or not.
Is this display of msg box by the main thread fine while the worker thread is running?.If the user says <yes>, the worker thread is made to return.
I have also read that worker threads must not try to launch any GUI window(message box, dialogs.). But here in my case the msg box is thrown by the main primary thread.
Waiting for suggestions
Best Regards
|
|
|
|
|
dp_76 wrote: Q1--> Is the above strategy fine?
This is the same thing as manipulating GUI objects from a worker thread since a ::SendMessage is issued in both cases. When using ::SendMessage the call will wait for the message to be handled before returning. If the receiving thread does not handle the message you will have a deadlock situation.
Even if you are fortunate and able to avoid a deadlock situation, your worker thread is waiting for the main thread to handle the message and your worker thread is "paused" until the main thread has handled the message. Usually this is not desired.
The use of ::PostMessage is recommended instead which will prevent a deadlock situation and also makes the worker thread continue while the main thread is handling the messages you've posted to it.
Regarding the message box issue the same thing as above is applicable.
If you are using ::SendMessage, the worker thread would be waiting for the call to return and here you may have a deadlock situation if you like to wait for the worker thread to finish by waiting on the thread handle.
The thing is do have a worker thread execute asynchronously as long as it does not use data that is shared between thread. If either thread is using shared data you would need some kind of synchronization object to prevent data corruption, e.g. critical section.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
|
Sounds fine. It is fine to display a message box in the worker thread - Although it is better if the UI thread does this as the worker can keep processing until the user makes his choice. Roger has a point when he makes his case for replacing SendMessage with PostMessage .
Steve
|
|
|
|
|
I want to show the thumbnails of html files to the user. As the thml file is of 600*400 I need to show the thumbnails in a list. So how do I convert the HTMl files output(the one which we see when we open the file in browser) into a image like bmp ot JPG
Regards,
Hemant Kulkarni
|
|
|
|