473,382 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem with dynamic fopen with windows mobile

Hi I am having a problem and can not for the life of me figure out what is wrong.
I have a program that iterates through every file in a directory using FindFirstFile and FindNextFile and add them to a linked list. Then after adding all the files I want to read them in one at a time and send them over a socket connection.

I am succesfully iterating through all the files adding them to the linked list and retrieving them from the linked list but when I try and open them for reading using fgetc(filename) it ternminates prematurelly with error code 32 (ERROR_SHARING_VIOLATION 32 ::The process cannot access the file because it is being used by another process. )

I looked long and hard for where the file may have been used by another process and not properly closed. In order to do that I added some debug statements and found out that if I open the file with a hardcoded name ie "fileName" and not with a char* that contains that file name everything works great. for example here is what I have



if((file = fopen("\\MyFilePath\\data\\file001.mfr","r")) != NULL) {
count = 0;
while((byte = fgetc(file)) != EOF) {
count++;
}
printf("%d bytes read,error and eof values %d and %d\n\n",count,ferror(file),feof(file));
}
fclose(file);

strcpy(filePathPtr,"\\MyFilePath\\data\\file001.mf r");
if((file = fopen(filePathPtr, "r") != NULL)) {
count = 0;
while((byte = fgetc(file)) != EOF) {
count++;
}
printf("File read with %d bytes and error values %d and %d\n",count,ferror(file),feof(file));
fclose(file);
if((file = fopen("\\MyFilePath\\data\\file001.mfr","r")) != NULL) {
count = 0;
while((byte = fgetc(file)) != EOF) {
count++;
}
printf("\n\nAfter I could not read it can I still read? %d bytes and error values %d and %d\n\n",count,ferror(file),feof(file));


The printout looks like this:
115 bytes read,error and eof values 0 and 16

File read with 0 bytes and error values 32 and 0
After I could not read it can I still read? 115 bytes and error values 0 and 16

The only thing I can think of is for Windows Mobile 5.0 there is something wrong with passing in a standard char*. Is there another way around this, or has anyone experienced this before and found a solution or work around.

Thanks in advance I have been bashing my head against the wall on this one for awhile.
Aug 28 '07 #1
0 3351

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: git_cs | last post by:
Hey, guys and gals Somedays ago, I had asked for the DES algorithm in C language. Although I have written the algorthim in C myself, I am facing a peculiar problem, which I hope some of u guys and...
0
by: Nick White [MSFT] | last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts: I invite you to peruse the list below of upcoming technical chats and Webcasts offered by the Windows Mobile and Embedded Devices...
1
by: Thomas | last post by:
Hi, I have written a Web Service using Axis C++ Server and a .Net Windows client. I considered every interoperability issue between Axis and .Net( Doc/Literal ...) The .Net Windows client can...
11
by: zaebos | last post by:
hi, i have this code which is part of a main program, to email from within the program a log file: int MailIt (char *mailserver, char *emailto, char *emailfrom, char *emailsubject, char...
2
by: yanlu06 | last post by:
I tried to use HTML2FPDF to generate dynamic local files and save the generated files on the server. I don't know why it gives me the following error message: " Warning:...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
11
by: julie.siebel | last post by:
I'm working on a rather complex booking system for building European trips, in a combination of SQL/VBScript/Javascript. There are tons of query string variables that get passed back and forth...
2
by: libish | last post by:
hi all, can any one help me to create dynamic forms in windows mobile application. here in my application, i'm requesting a server response, and the server response contains directions for the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.