|
-
Nov 2nd, 2009, 04:39 PM
#1
Thread Starter
Junior Member
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.
-
Nov 3rd, 2009, 03:31 AM
#2
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
-
Nov 3rd, 2009, 07:40 AM
#3
Thread Starter
Junior Member
Re: Saving Data from Mobile App
I dont know if this will work for a Mobile Application or will it?
-
Nov 3rd, 2009, 07:45 AM
#4
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
-
Nov 3rd, 2009, 08:39 AM
#5
Thread Starter
Junior Member
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.
-
Nov 3rd, 2009, 08:51 AM
#6
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
-
Nov 3rd, 2009, 09:47 AM
#7
Thread Starter
Junior Member
Re: Saving Data from Mobile App
Symbol Barcode Scanner with Windows Mobile 5.0. Need anything Else.
-
Nov 3rd, 2009, 09:58 AM
#8
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
-
Nov 3rd, 2009, 10:01 AM
#9
Thread Starter
Junior Member
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.
-
Nov 3rd, 2009, 10:02 AM
#10
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
-
Nov 3rd, 2009, 10:04 AM
#11
Thread Starter
Junior Member
Re: Saving Data from Mobile App
-
Nov 3rd, 2009, 10:06 AM
#12
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
-
Nov 3rd, 2009, 10:08 AM
#13
Thread Starter
Junior Member
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.
-
Nov 3rd, 2009, 10:12 AM
#14
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
-
Nov 3rd, 2009, 10:14 AM
#15
Thread Starter
Junior Member
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
-
Nov 3rd, 2009, 10:17 AM
#16
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
-
Nov 3rd, 2009, 10:42 AM
#17
Thread Starter
Junior Member
Re: Saving Data from Mobile App
ANd what would that do? How would i do that then using the code i posted?
-
Nov 3rd, 2009, 10:45 AM
#18
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
-
Nov 4th, 2009, 09:36 AM
#19
Thread Starter
Junior Member
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.
-
Nov 4th, 2009, 09:40 AM
#20
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
-
Nov 4th, 2009, 11:35 AM
#21
Thread Starter
Junior Member
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.
-
Nov 4th, 2009, 12:31 PM
#22
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
-
Nov 10th, 2009, 09:42 AM
#23
Thread Starter
Junior Member
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.
-
Nov 10th, 2009, 01:48 PM
#24
Frenzied Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|