IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Mobile .NET Discussion :

[Débutant][C#] Simple création de fichier


Sujet :

Windows Mobile .NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut [Débutant][C#] Simple création de fichier
    Bonjour à tous,

    j'ai mon appli sur un windows mobile 5.

    Je souhaiterais simplement créer un fichier dans le répertoire \My Documents mais il me marque IOException.

    Voici le code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    private void Write2File(string msg, string filePath)
            {
                try
                {
                    if (!File.Exists(filePath))
                    {
                        File.Create(filePath);
                    }
                    System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Append);
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
                    sw.WriteLine(msg);
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                }
                catch (IOException ioe)
                {
                    Write2File(ioe.StackTrace, "\\My Documents\\PDA_LOG.log");
                }
     
            }
    L'exception est catchée au niveau du File.Create(filepath);

    Et voici l'exception pas très explicite je dois le reconnaitre

    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.File.Create(String path, Int32 bufferSize)
    at System.IO.File.Create(String path)
    at NIS_2008_Sync_Data.SyncNisData.Write2File(String msg, String filePath)
    at NIS_2008_Sync_Data.SyncNisData.dropTables()
    at NIS_2008_Sync_Data.SyncNisData.getNisData()
    at NIS_2008_Sync_Data.SyncDataForm.buttonImport_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 NIS_2008_Sync_Data.LaunchSyncDataForm.Main()

    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.File.Create(String path, Int32 bufferSize)
    at System.IO.File.Create(String path)
    at NIS_2008_Sync_Data.SyncNisData.Write2File(String msg, String filePath)
    at NIS_2008_Sync_Data.SyncNisData.getNisData()
    at NIS_2008_Sync_Data.SyncDataForm.buttonImport_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 NIS_2008_Sync_Data.LaunchSyncDataForm.Main()

    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.File.Create(String path, Int32 bufferSize)
    at System.IO.File.Create(String path)
    at NIS_2008_Sync_Data.SyncNisData.Write2File(String msg, String filePath)
    at NIS_2008_Sync_Data.SyncNisData.getNisData()
    at NIS_2008_Sync_Data.SyncDataForm.buttonImport_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 NIS_2008_Sync_Data.LaunchSyncDataForm.Main()
    Je suppose que c'est un problème de droits.

    Comment puis-je résoudre ce problème??

    D'avance merci pour vos réponses.

  2. #2
    Expert confirmé
    Avatar de smyley
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    6 270
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 6 270
    Par défaut
    tu pourrai afficher le contenu de ioe.Message à la place ?

  3. #3
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut
    ioe.Message affiche: IOException et c'est tout

  4. #4
    Expert confirmé
    Avatar de smyley
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    6 270
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 6 270
    Par défaut
    que contient filePath au moment du crash ?

  5. #5
    Membre émérite

    Homme Profil pro
    Senior Développeur JEE
    Inscrit en
    Avril 2002
    Messages
    795
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Belgique

    Informations professionnelles :
    Activité : Senior Développeur JEE
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2002
    Messages : 795
    Par défaut
    C'est bon j'ai trouvé mon problème.

    j'utilise un fichier xml comme fichier de config. Et j'utilise XmlDataReader pour parser et récupérer les info de config.

    et dans un des tags je mettais le path mais avec des \ doublées.

    En mettant des \ simples, le problème est résolu.

    pour ton aide

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [SOAP] [WSDL] [PHP] Problème création du fichier WSDL (Débutant)
    Par Guybrush113 dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 19/09/2007, 12h45
  2. [MEX] [Débutant] Création de fichier Mex C
    Par brel380 dans le forum MATLAB
    Réponses: 1
    Dernier message: 06/06/2007, 12h47
  3. [Delphi 2005] Débutant avec problème de création de fichier
    Par Patcdc dans le forum Bases de données
    Réponses: 2
    Dernier message: 06/06/2005, 18h41
  4. Réponses: 8
    Dernier message: 03/09/2003, 00h47
  5. création de fichiers .x
    Par Pazz dans le forum DirectX
    Réponses: 1
    Dernier message: 03/12/2002, 00h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo