Saving Data from Mobile App
I have a multi line textbox that has data string that are like the following:
07603,5,0930341,
07603,5,0930342,
07603,5,0930343,
07603,5,0930344,
What i want to beable to to is what ever value is in my textbox(above data), to save that to a textfile on the mobile scanner.
Any help would be greatly appreciated.
Re: Saving Data from Mobile App
Hey,
If would have said that TextReader and TextWriter would be a good place to start.
You can find an example of this here:
http://www.dotnetheaven.com/UploadFi...WriterGAG.aspx
Hope that helps!!
Gary
Re: Saving Data from Mobile App
I dont know if this will work for a Mobile Application or will it?
Re: Saving Data from Mobile App
Hey,
Why would it not?
This article is written specifically for the .Net Compact Framework, and also the MSDN Documentation suggests that it is supported:
http://msdn.microsoft.com/en-us/libr...extwriter.aspx
Have you tried it?
Gary
Re: Saving Data from Mobile App
Ok im getting somewhere now. But do you know what the path on a mobile barcode scanner would be instead of a C: drive?
Or a path on the scanner where i could store this file too.
Re: Saving Data from Mobile App
Hey,
That really depends on the software that you are using.
If you provide some more information, we might be able to help.
Gary
Re: Saving Data from Mobile App
Symbol Barcode Scanner with Windows Mobile 5.0. Need anything Else.
Re: Saving Data from Mobile App
Hey,
Well yes. I have never used that before, so I know next to nothing about it :)
Does this install on the Mobile Device, or is it a stand alone device? If so, how does it connect?
To be honest, I don't even know why you need this interaction between the device and the scanner, i.e. the text file.
Perhaps some more information as to exactly what you are trying to do will help.
Gary
Re: Saving Data from Mobile App
The program im creating will be loaded on this scanner. From the scanner the mobile device will scan barcodes and save in a textbox on the program. From there when done scanning the device will create a text file and store it on the scanner. Next the scanner is loaded into the crade and via Active Sync it will download to a computers desktop.
Re: Saving Data from Mobile App
Hey,
Okay, you seem to be mixing terminologies here, or I am missing something.
Is the barcode scanner a completely separate device from the windows mobile device, or actually one and the same device?
Can you provide a link to the hardware that you are using?
Gary
Re: Saving Data from Mobile App
Re: Saving Data from Mobile App
Hey,
Ok, this is starting to make more sense.
So, to recap...
You can get the scanner to return the code to the TextBox, correct?
And you can write these values out to a text file, correct?
So, am I right in thinking that the only problem you are having is finding that file on the file system of the Mobile Device?
Gary
Re: Saving Data from Mobile App
Yeah basically. Im gettin all the data i need into my multiline textbox. From there all i need to do is save whats in that textbox to a text file on the mobile device. And i need to know a default root is on the mobile device.
Re: Saving Data from Mobile App
Hey,
Can you show the code that you are using to write out the file?
By default, you are probably writing the file to the folder in which the application lives on the Mobile Device.
On the device, go Start | Programs, then select File Explorer. From here, go to "My Device", and then browse down through Program Files, and you should find where you application is installed.
There are some built in methods that you can use to help you get this in code:
i.e. http://msdn.microsoft.com/en-us/library/aa457089.aspx
Gary
Re: Saving Data from Mobile App
Thats what im using, so i think i need to put a path in there instead of C:...
Dim writeFile As System.IO.TextWriter = New _
StreamWriter("c:\textwriter.txt")
writeFile.WriteLine(txtScan.Text)
writeFile.Flush()
writeFile.Close()
writeFile = Nothing
Re: Saving Data from Mobile App
Hey,
Ah, I see what you are getting at :)
You should be able to simply do this:
Code:
Dim writeFile As System.IO.TextWriter = New _
StreamWriter("textwriter.txt")
writeFile.WriteLine(txtScan.Text)
writeFile.Flush()
writeFile.Close()
writeFile = Nothing
Which would write it into the same folder as your application is running from. Or, you could construct a path to another location on the file system.
You might want to think about wrapping the StreamWriter in a using statement, rather than explicitly calling Close().
Gary
Re: Saving Data from Mobile App
ANd what would that do? How would i do that then using the code i posted?
Re: Saving Data from Mobile App
Hey,
Did you think to search for what I suggested?
http://msdn.microsoft.com/en-us/libr...hh(VS.80).aspx
Basically, you would modify the code as follows:
Code:
Using writeFile As System.IO.TextWriter = New _
StreamWriter("textwriter.txt")
writeFile.WriteLine(txtScan.Text)
End Using
This then takes care of closing off the object for you, when it is going out of scope. Meaning that you don't have to explicitly call close.
Gary
Re: Saving Data from Mobile App
One more question on this. What if i dont want the name of the file to be textwriter.txt evertime. How could i do it to string together a file name from my textboxes or so that if there is a file named textwriter.txt, if i were to save another file it would save it as textwriter1.txt, and so on...
Thanks.
Re: Saving Data from Mobile App
Hey,
You could either do something like this:
Code:
Using writeFile As System.IO.TextWriter = New _
StreamWriter(String.Format("{0}.txt", TextBox1.Text)
writeFile.WriteLine(txtScan.Text)
End Using
Or, you could throw up a SaveFileDialog to allow the user to provide a filename:
http://msdn.microsoft.com/en-us/libr...iledialog.aspx
Gary
Re: Saving Data from Mobile App
The saved dialog box wont work for this applcation. It will, but i dont want to use that, i want this as automated as i can.
So back to my question, i dont think i want to use a txtbox name, id rather use a static name like textwriter.txt But how can i use it so that if theres a file already there, that it will name it like this textwriter1.txt.
Thanks.
Re: Saving Data from Mobile App
Hey,
You should be able to use File.Exists:
http://msdn.microsoft.com/en-us/libr...le.exists.aspx
This will allow you to verify if the file already exists, if it does, you can change it to include a numeric identifier. You could also look into keep a count of the files that have been created, or you could append the current date and time onto the file name.
Gary
Re: Saving Data from Mobile App
I have 1 more request for this application. And i need some help with a counter. I have a textbox called txtCounter. What i want is everytime the focus is on txtscan to count start at 0, and just go up by one.
Re: Saving Data from Mobile App
Hi,
declare a module level variable
Private iCtr as integer = 0
Then in the 'gotfocus' event of txtScan do
iCtr += 1
txtScan.text = iCtr
That should do it