Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi all,

the last posting have solved by myself..

 

Now I am advancing to build program on smart device (pocket PC).

Function I want to do now is write to text file again.

 

Can I really declare my text file like this?

string fileName = "c:\\delivery.txt";
System.IO.StreamWriter writer = new System.IO.StreamWriter(fileName,True);

 

OK..

I been trying to find out the String manipulation too...

Such in VB 6 there is Mid(0,hhh)

to limit the string size.

But How to do in C#?

Posted

On your first question:

That declaration seems right. It should open the c:\delivery.txt file for append. You can use the writer object to send text to it.

 

On the second. Look into the String object.

Instead of Mid(<start>, <length>), you can now use SubString:

String myString = "blabla";

String subString = myString.SubString(2, 2);

 

subString would contain "ab"

 

The String object has quite a few more handy methods ;).

Nothing is as illusive as 'the last bug'.
Posted

Sorry its misconverzation there...

 

Sorry Wile.. what I really mean in string manipulation is actually string modifier....

 

I programming c.. we write

printf("%6d, 123");

so the output will be indent for 6 space to fit 123

I want to know how do we do that in C#.

Books I have here does not mention about this...

 

And the second thing is, is it the file system for pocket pc is the same as desktop pc?

I tried to run on emulator which include in VS.NET.

The program cause run time error.

Posted

I can't help you with the pocket pc filesystem, except saying that my pocket pc doesnt even have a C-root (c:\) so it is probably quite a bit different.

 

 

For printf/sprintf formatting thingies, there is String.Format (this is a static method, so use it on the String class, not on an object).

 

This uses { and } instead of the '%'. Your code would be something like String.Format("{0:6}", 123);

 

Quick copy & paste of a part of MSDN library about the format method gives another example:

  Quote

If the value of format is, "Brad's dog has {0,-8:G} fleas.", arg[0]is an Int16 with the value 42, (and in this example, underscores represent padding spaces) then the return value will be:

 

"Brad's dog has 42______ fleas."

Nothing is as illusive as 'the last bug'.
  • 4 weeks later...
Posted (edited)

StreamWriter and StreamWriter are supported by the compact framework. From what I gather about the Pocket PC is that there is no C:\. To create a directory in the main \(root folder or My device folder equivalent to C:\ on yer PC) you'd say

StreamWriter tw = new StreamWriter("\\myfile.txt");

 

to create a file in My documents you'd say

StreamWriter tw = new StreamWriter("\\My Document\\mydoc.txt");

Edited by Iceplug

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...