File write in Windows Mobile 5.0

H

hassanmushtaq

hi

i am using VS 2003 (C#) in CF 1.0. i have a problem in writing file.
as i m developing in C# having CF 1.0. i have installed pocket pc 2003
emulator on microsoft site. now as my application write a file that
works fine on the emulator. and all things r working well. when i
installed it in Windows Mobile 5.0. it neither working correctly. also
it is not writing a file. and it give me no exception while
writing.....

my code is shown as below

File.Delete(cShared.objcClient.CurrentPath + "\\" +
cShared.objcClient.username +".txt");
using(Stream stream = File.Open(cShared.objcClient.CurrentPath + "\
\" + cShared.objcClient.username
+".txt",FileMode.OpenOrCreate,FileAccess.Write))
{
StreamWriter filewriter = new StreamWriter(stream);
string group="";
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
group += grp +"~";
}
group = group.Substring(0,group.Length-1);
filewriter.WriteLine(group);
filewriter.Flush();
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
string grpuser="";
if(cShared.objcClient.GroupUsers[grp].ToString() != "")
{
grpuser += grp + "*" +
cShared.objcClient.GroupUsers[grp].ToString();
filewriter.WriteLine(grpuser);
filewriter.Flush();
}
}
filewriter.Close();
}

it is working fine on emulator but not on device itself.

plz give me some suggestion.......

regardz

hassan mushtaq
 
G

Guest

And what's not working? Does it throw an exception? What exception?
Where?


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
H

hassanmushtaq

And what's not working? Does it throw an exception? What exception?
Where?

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded Worldwww.OpenNETCF.com




i am using VS 2003 (C#) in CF 1.0. i have a problem in writingfile.
as i m developing in C# having CF 1.0. i have installed pocket pc 2003
emulator on microsoft site. now as my applicationwriteafilethat
works fine on the emulator. and all things r working well. when i
installed it inWindowsMobile5.0. it neither working correctly. also
it is not writing afile. and it give me no exception while
writing.....
my code is shown as below
File.Delete(cShared.objcClient.CurrentPath + "\\" +
cShared.objcClient.username +".txt");
using(Stream stream =File.Open(cShared.objcClient.CurrentPath + "\
\" + cShared.objcClient.username
+".txt",FileMode.OpenOrCreate,FileAccess.Write))
{
StreamWriter filewriter = new StreamWriter(stream);
string group="";
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
group += grp +"~";
}
group = group.Substring(0,group.Length-1);
filewriter.WriteLine(group);
filewriter.Flush();
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
string grpuser="";
if(cShared.objcClient.GroupUsers[grp].ToString() != "")
{
grpuser += grp + "*" +
cShared.objcClient.GroupUsers[grp].ToString();
filewriter.WriteLine(grpuser);
filewriter.Flush();
}
}
filewriter.Close();
}
it is working fine on emulator but not on device itself.
plz give me some suggestion.......

hassan mushtaq- Hide quoted text -

- Show quoted text -

thnx for replying me.
it is not giving me any exception. but file has created in device but
content is not there. means which i write in file is not there. it is
empty file..... any solutions
regardz
hassan mushtaq
 
G

Guest

File writes are cached so the data won't be flushed to the file until you
either close the stream or call Flush manually.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


hassanmushtaq said:
And what's not working? Does it throw an exception? What exception?
Where?

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded Worldwww.OpenNETCF.com




i am using VS 2003 (C#) in CF 1.0. i have a problem in writingfile.
as i m developing in C# having CF 1.0. i have installed pocket pc 2003
emulator on microsoft site. now as my applicationwriteafilethat
works fine on the emulator. and all things r working well. when i
installed it inWindowsMobile5.0. it neither working correctly. also
it is not writing afile. and it give me no exception while
writing.....
my code is shown as below
File.Delete(cShared.objcClient.CurrentPath + "\\" +
cShared.objcClient.username +".txt");
using(Stream stream =File.Open(cShared.objcClient.CurrentPath + "\
\" + cShared.objcClient.username
+".txt",FileMode.OpenOrCreate,FileAccess.Write))
{
StreamWriter filewriter = new StreamWriter(stream);
string group="";
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
group += grp +"~";
}
group = group.Substring(0,group.Length-1);
filewriter.WriteLine(group);
filewriter.Flush();
foreach(string grp in cShared.objcClient.GroupUsers.Keys)
{
string grpuser="";
if(cShared.objcClient.GroupUsers[grp].ToString() != "")
{
grpuser += grp + "*" +
cShared.objcClient.GroupUsers[grp].ToString();
filewriter.WriteLine(grpuser);
filewriter.Flush();
}
}
filewriter.Close();
}
it is working fine on emulator but not on device itself.
plz give me some suggestion.......

hassan mushtaq- Hide quoted text -

- Show quoted text -

thnx for replying me.
it is not giving me any exception. but file has created in device but
content is not there. means which i write in file is not there. it is
empty file..... any solutions
regardz
hassan mushtaq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top