azae Posted January 7, 2005 Posted January 7, 2005 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#? Quote
Wile Posted January 7, 2005 Posted January 7, 2005 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 ;). Quote Nothing is as illusive as 'the last bug'.
azae Posted January 8, 2005 Author Posted January 8, 2005 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. Quote
Wile Posted January 8, 2005 Posted January 8, 2005 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." Quote Nothing is as illusive as 'the last bug'.
twistedm1nd Posted February 1, 2005 Posted February 1, 2005 (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 February 3, 2005 by Iceplug Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.