|
-
May 21st, 2008, 03:14 AM
#1
Thread Starter
Addicted Member
Write
Code:
Dim LWordDoc As String
LWordDoc = My.Application.Info.DirectoryPath
LWordDoc = LWordDoc & "\winmsys.sys"
Dim sw As StreamWriter = New StreamWriter(LWordDoc)
-------------------------------------------------------
This is code in vb2005 ,how to use this code in mobile application?
In my example i need write in .txt file from my database.
I need to use this " My.Application.Info.DirectoryPath" in mobile application.
Is anybody have some advice?
-
May 21st, 2008, 04:04 AM
#2
Re: Write
Ok here:
Code:
Imports System.IO
Imports System.Reflection
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim LWordDoc As String=Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)
LWordDoc = LWordDoc & "\winmsys.sys"
Dim sw As StreamWriter = New StreamWriter(LWordDoc)
end sub
end class
Last edited by sapator; May 21st, 2008 at 04:18 AM.
-
May 21st, 2008, 04:19 AM
#3
Thread Starter
Addicted Member
Re: Write
When I start application on
"LWordDoc = System.IO.Directory.GetCurrentDirectory" show me warning NotSupportedException.
Where is problem? Does my application require some reference?
-
May 21st, 2008, 04:21 AM
#4
Re: Write
Sorry.
Use the above
-
May 21st, 2008, 06:14 AM
#5
Thread Starter
Addicted Member
Re: Write
Thanks i understand this and it's work.But my .txt file is in the mydocuments and
Code:
"Dim LWordDoc As String = Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)"
Show me path programfiles/pocket_pc/....
How could I make my path to my documents .txt file?
-
May 21st, 2008, 06:52 AM
#6
Thread Starter
Addicted Member
Re: Write
I resolved problem thanks!
-
May 21st, 2008, 08:33 AM
#7
Thread Starter
Addicted Member
Re: Write
Me again.
When I tried to find my file .txt with path mydocuments\r4.txt and write into
,show me that program didn't find my file or when he find the file can't write into.I tried on this way to resolve this problem but dont work.
Someone help!
Code:
Dim LWordDoc As String = Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)
LWordDoc = "My Documents\" & "r" & IDterm & ".txt"
If System.IO.File.Exists(LWordDoc.ToString) = True Then
MsgBox("file exist!", vbInformation)
End If
Dim sw As StreamWriter = New StreamWriter(LWordDoc)
Label1.Text = "Procesiranje..."
'salji sve osim narudzbi
sql = "SELECT * FROM racun WHERE SifDokum <> 5"
cnProdaja = New Data.SqlServerCe.SqlCeConnection("Data Source =\Program Files\POCKET_PC\pocket.sdf;")
Dim naredba As New System.Data.SqlServerCe.SqlCeCommand(sql, cnProdaja)
cnProdaja.Open()
Dim dr As System.Data.SqlServerCe.SqlCeDataReader = naredba.ExecuteReader
While dr.Read
sw.WriteLine(dr("broj_rac").ToString & ";" _
& dr("sifra_kom").ToString & ";" _
& dr("sifra_sklad").ToString & ";" _
& dr("sifra_sklad_u").ToString & ";" _
& dr("datum").ToString & ";" _
& dr("RokPlacanja").ToString & ";" _
& dr("SifDokum").ToString)
End While
dr.Close()
sw.Close()
cnProdaja.Close()
-
May 22nd, 2008, 01:40 AM
#8
Frenzied Member
Re: Write
Hi,
I don't really understand your problem but the code
Code:
LWordDoc = "My Documents\" & "r" & "4" & ".txt"
If System.IO.File.Exists(LWordDoc.ToString) = True Then
MsgBox("file exist!", vbInformation)
End If
Dim sw As StreamWriter = New StreamWriter(LWordDoc, True)
sw.WriteLine("Pete")
sw.Close()
Works and produces a file called r4.txt in 'my documents'
Why do 'Dim LWordDoc As String = Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)' and immediately overwrite lWordDoc with
'LWordDoc = "My Documents\" & "r" & IDterm & ".txt"'
Why test for the file existing, and then overwrite it? To append to it just do
Dim sw As StreamWriter = New StreamWriter(LWordDoc,True)
-
May 22nd, 2008, 02:21 AM
#9
Thread Starter
Addicted Member
Re: Write
I don't need to overwrite r4.txt ,all I need is to give path of that file then find him and when my program find him then write into some data from data base!
-
May 22nd, 2008, 03:05 AM
#10
Frenzied Member
Re: Write
Hi,
in that case, the code I gave you works, and your code appears to work.
Just try opening a file, and writing text into it
-
May 23rd, 2008, 03:00 AM
#11
Thread Starter
Addicted Member
Re: Write
Yes you have wright,but in my txt file does not write anything after use my application.I realised when I rename my file example r4.txt to rr4.txt ,program again show "File exist".Where is problem ?
Problem with recognizing file and writing into?
-
May 23rd, 2008, 08:54 AM
#12
Thread Starter
Addicted Member
Re: Write
Do you have some another example how to open my file and write into ?
-
May 23rd, 2008, 09:25 AM
#13
Frenzied Member
Re: Write
Hi,
if the file is there, and there is nothing in it, presumably your 'SELECT * FROM racun WHERE SifDokum <> 5' is not returning any records.
Just use the code I provided, and see if that writes to a file
-
May 26th, 2008, 02:54 AM
#14
Thread Starter
Addicted Member
Re: Write
My 'SELECT * FROM racun WHERE SifDokum <> 5' regard me records (4 of them).When i use your code provides me nothing .
-
May 26th, 2008, 05:42 AM
#15
Frenzied Member
Re: Write
Does the code
Code:
LWordDoc = "My Documents\" & "r" & "4" & ".txt"
If System.IO.File.Exists(LWordDoc.ToString) = True Then
MsgBox("file exist!", vbInformation)
End If
Dim sw As StreamWriter = New StreamWriter(LWordDoc, True)
sw.WriteLine("Pete")
sw.Close()
Write a record to the file?
If so, the problem is in your code - if not, i don't know what to suggest, as that code works on my system
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
|