Bonjour,
J'étudiie une application sous visual studio 2008 en c# sur windows Mobile 5.0 .
Cette application permettrait :
. D'avoir un écran de saisie avec quelque champs texte ( ex : textBox.Text )
. Enverrait lors d'un clic sur un boutton les champs saisis sous la forme d'un fichier texte ( communication pda - pc ActiveSync via cable usb ) .
. Exécuterait une application ( *.bat ) qui lancerait un autre programme traitant les données ainsi transférées
. Pour écrire le fichier texte sur le pda ok pas de soucis avec :
. Mais pour écrire sur l'ordinateur auquel est relié par activesync le pda , je ne trouve pas un moyen d'écrire, par quel moyen faudrait il le faire ( moyen essayé ) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 String chemin = @"file.txt"; StreamWriter monStreamWriter = new StreamWriter(chemin); String chaineSortie = textBox1.Text; monStreamWriter.WriteLine(chaineSortie); monStreamWriter.Close();
Sur le poste en question le dossier c:\temp a été partagé et accessible à tous en lecture\écriture .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 String chemin = @"\\ip.poste\temp\file.txt"; StreamWriter monStreamWriter = new StreamWriter(chemin); String chaineSortie = textBox1.Text; monStreamWriter.WriteLine(chaineSortie); monStreamWriter.Close();
Je voudrai écrire par chemin unc ( \\serveur\répertoire partagé\ )
Une exception ( en catch ) se produit
System.IO.IOException, en débug ayant un HResult -2146232800
Erreur :
Tout ce qui m'importe serait de pouvoir transférer ce fichier du pda vers le pc vers lequel il est connecté via activeSync .at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
at SmartDeviceProject1.sortie.button3_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
at System.Windows.Forms.Application.Run(Form fm)
at SmartDeviceProject1.Program.Main()
J'ai essayé également avec des :
Mais c'est la même chose .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 String chemin = @"\\ip.poste\temp\file.txt"; System.IO.FileStream fs = new System.IO.FileStream(chemin, System.IO.FileMode.Append); System.IO.StreamWriter sw = new System.IO.StreamWriter(fs); sw.WriteLine(chaineSortie); sw.Flush(); sw.Close(); fs.Close();
Quelqu'un aurait il déjà été confronté à ce problème ?
. De plus comment lancer un .bat situé dans un répertoire précis sur le poste où est connecté le pda via ActiveSync ?
Merci .
Partager