Rechercher un fichier

Résolu
cocodu67... Messages postés 3153 Date d'inscription jeudi 28 janvier 2010 Statut Membre Dernière intervention 4 avril 2024 - 1 mars 2014 à 14:05
cocodu67... Messages postés 3153 Date d'inscription jeudi 28 janvier 2010 Statut Membre Dernière intervention 4 avril 2024 - 8 mars 2014 à 21:50
Bonjour,

J'ai un fichier qui se créé sur mon serveur MYSQL mais le problème c'est que le chemin complet change selon le logiciel utilisé (wamp server, uwamp, etc etc).

J'aimerais donc pouvoir rechercher ce fichier afin de le déplacer.

La discussion : http://www.commentcamarche.net/forum/affich-29793859-retrouver-le-fichier-qui-vient-d-etre-sauvegarde

Merci d'avance pour votre aide

1 réponse

cocodu67... Messages postés 3153 Date d'inscription jeudi 28 janvier 2010 Statut Membre Dernière intervention 4 avril 2024 1
8 mars 2014 à 21:50
Oups j'ai zappé ce topic.

J'ai trouvé la solution :


string Path = Application.ExecutablePath;
Path = Directory.GetParent(Path).ToString();
Path = Directory.GetParent(Path).ToString();
Path = Directory.GetParent(Path).ToString();
Path = Path.Replace("\\", "/");
Path = Path + "/historique/historique.txt";

maRequeteHistoComplet = "SELECT * FROM tblhistorique INTO OUTFILE @Chemin FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n'";
maCommandeHistoComplet = new MySqlCommand(maRequeteHistoComplet, maConnexion);
maCommandeHistoComplet.Parameters.Add(new MySqlParameter("@Chemin", MySqlDbType.String, 35));
try { maCommandeHistoComplet.Parameters["@Chemin"].Value = Path; }
catch { };

try
{
maCommandeHistoComplet.Connection.Open();

maCommandeHistoComplet.ExecuteScalar();

maCommandeHistoComplet.Connection.Close();
}
catch { MessageBox.Show("Erreur lors de la création du fichier"); }

string Path1 = Application.ExecutablePath;
Path1 = Directory.GetParent(Path).ToString();
Path1 = Directory.GetParent(Path).ToString();
Path1 = Directory.GetParent(Path).ToString();
Path1 = Path1 + "\\historique.txt";
try
{
Process proc = new Process();
proc.StartInfo = new ProcessStartInfo(Path1);
proc.Start();
}
catch
{
MessageBox.Show("Erreur, fichier non trouvé");
}

La fin me permet d'ouvrir le fichier.

En faite le problème était lié au sens des slash et il fallait aussi mettre le chemin entier dans la requête.
0
Rejoignez-nous