|
Are you able to manually open the file and view its contents?
|
|
|
|
|
Yes. It contains a 55 row of numbers separated by commas. I produce first 5 rows of my file's content.
0,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
1,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
2,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
3,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
4,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
5,79,76,6,2222,126,1,15,23,88,88,6,14,"3/9",0
I've to read a single line at a time. I then have to store each value to a structure element.
|
|
|
|
|
Check the attributes of the output file test.txt if it already exists. Check if it is read only.
|
|
|
|
|
|
Is it possible to do a GetLastError() or _get_errno() and see the error code?
|
|
|
|
|
When I print the
GetLastError() , it prints 183.
|
|
|
|
|
Use errlook to check the meaning of error codes. In this case 183 means: Cannot create a file when that file already exists. Either add options to recreate the file even if it exists, or ensure that your filename is unique.
It's time for a new signature.
|
|
|
|
|
A couple of things to consider...
- why are you calling open()? It's more common to see something like:
std::ifstream input( "c://test.txt" );
if( input )
{
std::string text;
std::getline( input, text );
}
- Don't bother manually closing the file - it's completely pointless
- Are you sure you want to read one character from a file then try and write 150? Especially into something that's a constant block of memory.
None of these things explain why the file isn't being opened. The Error number you're getting seems to imply the file already exists which is an error I'd expect from trying to open an ofstream. Are you doing the GetLastError immediately after calling myfile.open()?
Cheers,
Ash
|
|
|
|
|
T.RATHA KRISHNAN wrote: std::string filename = "E://Work//Data//playerdata.txt";
Try:
std::string filename = "E:/Work/Data/playerdata.txt";
or
std::string filename = "E:\\Work\\Data\\playerdata.txt";
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello,
I'm using a small program that notify me when a file size change inside a directory. The program worked perfect under Win XP, now in Windows 7 the size changes are ignored for long periods and notifications are not in sync with the changes.
At first glance that could be seen as something related to caching/flushing differences between XP and Win 7 but I verified that the file I'm monitoring is being flushed to the disk and is not staying in cache.
I used the command tail -f monitoredfile.txt displaying the file content as it is updated and I was able to see all the changes in real time but my monitor program wasn't reporting any file size change.
This is the monitor program:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
void RefreshDirectory(LPTSTR);
void RefreshTree(LPTSTR);
void WatchDirectory(LPTSTR);
int _tmain(int argc, TCHAR *argv[])
{
if(argc != 2)
{
_tprintf(TEXT("Usage: %s <dir>\n"), argv[0]);
return 1;
}
WatchDirectory(argv[1]);
}
void WatchDirectory(LPTSTR lpDir)
{
DWORD dwWaitStatus;
HANDLE dwChangeHandles[2];
TCHAR lpDrive[4];
TCHAR lpFile[_MAX_FNAME];
TCHAR lpExt[_MAX_EXT];
_tsplitpath_s(lpDir, lpDrive, 4, NULL, 0, lpFile, _MAX_FNAME, lpExt, _MAX_EXT);
lpDrive[2] = (TCHAR)'\\';
lpDrive[3] = (TCHAR)'\0';
dwChangeHandles[0] = FindFirstChangeNotification(
lpDir,
FALSE,
FILE_NOTIFY_CHANGE_SIZE);
while (TRUE)
{ printf("\nWaiting for notification...\n");
dwWaitStatus = WaitForMultipleObjects(1, dwChangeHandles, FALSE, INFINITE);
switch (dwWaitStatus)
{
case WAIT_OBJECT_0:
_tprintf(TEXT("Directory (%s) changed.\n"), lpDir);
if (FindNextChangeNotification(dwChangeHandles[0]) == FALSE)
{
printf("\n ERROR: FindNextChangeNotification function failed.\n");
ExitProcess(GetLastError());
}
break;
default:
printf("\n ERROR: Unhandled dwWaitStatus.\n");
ExitProcess(GetLastError());
break;
}
}
}
|
|
|
|
|
It probably is a permission issue.
Try running the program from an elevated command prompt.
|
|
|
|
|
I tried with UAC OFF and ON, running as admin, etc. it's more related to a caching issue I guess. In the meanwhile I found a turnaround that made it work, I run a script on the background that apply the touch command every 100ms or so to the file I'm monitoring, it seems it forces a flush and then the changes are detected by my program...
Maybe that will give more clues to find a better solution.
Thanks,
|
|
|
|
|
Does argv[1] refer to a remote computer? Do you have the "backup file and directories" privilege?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
argv1 refers to the directory you want to monitor i.e. monitor c:\tmp
|
|
|
|
|
auriga19 wrote: argv1 refers to the directory you want to monitor i.e. monitor c:\tmp
I'm full aware of that. When FindFirstChangeNotification() fails to receive notification, does argv[1] refer to a remote computer?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
No, it refers to a directory on the local computer.
|
|
|
|
|
Ok, then the redirector is likely not the problem.
Just for grins, did you enable the "backup file and directories" privilege?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I just checked, I have those privileges enabled.
|
|
|
|
|
We can HOOKAPI. Such as "MessageboxA / W" or "OpenProcess" and so on. Then we can Hook the other?
For example,Hook "PEXCEPTION_POINTERS"?
<br />
LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)<br />
//This is our definition of the function,This is an internal function and Not exported.It isn't API HOOK it so we can not have any way to HOOK PEXCEPTION_POINTERS?
If it can, then how to write?
|
|
|
|
|
You want to hook 004381230 right?
Actually API hooking technique is for hooking APIs. I dont think PEXCEPTION_POINTERS can be hooked.
If tell ur need, may be i can help u.
Величие не Бога может быть недооценена.
|
|
|
|
|
Does "004381230" mean?
|
|
|
|
|
I have a multidoctemplate app, call it MyApp. For the default doc-view-frame of MyAppDoc-MyAppView-CChildFrame, I override the frame ActivateFrame to show the frame maximized. I added another doc-view-frame set, NewDoc-NewView-NewFrame, NewFrame derived from CMDIChildWnd. I override NewFrame ActivateFrame to show it normal. When I create and show a NewDoc object, it displays correctly but now my MapAppView is no longer maximized but cascaded with the NewView object. Why would anything I do with NewView affect anything I had done with MyAppView? I want MyAppView to continue to be maximized but NewView to be normal since I may create a lot of NewView objects and I want them cascaded when they are first shown. Thanks in advance.
|
|
|
|
|
That's the default behavior/implementation. If one child frame is maximized, so are the others when activated.
If you want one child frame maximized while the others are not, you will have to make it happen yourself. One suggestion would be to intercept the message when the user maximizes the window and then just resize it to the size needed and remove borders and other window decorations by modifying the window style. There are some things to take care of though, like when the main frame size changes, so should the 'maximized' child frame.
|
|
|
|
|
Thank you for the response. I tried that by overriding OnSize in both the child frame I want to keep maximized and the others I want to cascade. But the ones I want to cascade still come up maximized. I'll keep fiddling around with it.
|
|
|
|
|
Hello, id like to connect to a http server, preferably in a multiplatfrom working way so the code will work on linux and windows, a windows only way is fine for now aswell i guess (c/c++ only).
After the connection is established i want to check if a file exists.
Open for any function recommendations /papers etc.
Just anything.
Thanks.
modified on Wednesday, June 30, 2010 11:49 AM
|
|
|
|
|