Bonjour à tous!
Encore une question concernant Windows Mobile...

J'ai fait une petite application contenant une listbox dans laquelle j'affiche les fichiers (et dossiers) que contient le sous-dossier "test" où est installée mon application.
Le programme marche très bien sous l'émulateur Win Mobile 6.1 Pro - CF3.5 et me liste mes fichiers mais pas sur mon PPC (HTC TyTN2 WinMobile 6.1 Pro - CF 3.5).
Y a-t-il une erreur dans mon code?
using
System;
using
System.Diagnostics;using
System.IO.Compression;using
System.Runtime.InteropServices;using
System.Linq;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;namespace
testlistfolder{
publicpartialclassFrmMain : Form{
publicstring strCurrentDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);public FrmMain(){
InitializeComponent();
lsSkinList.Items.Clear();
strCurrentDir = strCurrentDir +
"\\test\\";AllFilesInDirectory(strCurrentDir);
}
privatevoid btnLoadSkins_Click(object sender, EventArgs e){
try{
// Since the FindString loops infinitely, determine if we found first item again and exit.if (lsSkinList.SelectedItem.ToString() == "\\.."){
strCurrentDir =
"";strCurrentDir = System.IO.
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);AllFilesInDirectory(strCurrentDir);
}
else{
try{
MessageBox.Show(lsSkinList.GetItemText(lsSkinList.SelectedItem));}
catch(Exception ex)
{
//handle any errors that occurred
MessageBox.Show("ERROR: no file selected. " + ex.Message);strCurrentDir =
"";strCurrentDir = System.IO.
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);AllFilesInDirectory(strCurrentDir);
}
}
}
catch (Exception ex){
//handle any errors that occurredMessageBox.Show(ex.Message);}
}
privatevoid lsSkinList_SelectedIndexChanged(object sender, EventArgs e){
}
publicvoid AllFilesInDirectory(string dir){
//always use a try...catch to deal //with any exceptions that may occurtry{
//first make sure the directory exists//if it doesnt and we try to delete the //files an exception is thrownif (!System.IO.Directory.Exists(dir)){
//errorMessageBox.Show("Folder " + dir + " cannot be found! Please retry your request");}
else{
// add root folder// lsSkinList.Items.Add("\\..");lsSkinList.Items.Clear();
//retrieve all the files and put them into a string arraystring[] files = System.IO.Directory.GetFiles(dir);string[] folders = System.IO.Directory.GetDirectories(dir);string str;lsSkinList.BeginUpdate();
//now loop through all the foldersforeach (string folder in folders){
foreach (string file in files){
// Replace string str = file;
str = str.Replace(strCurrentDir,
""); // lsSkinList.Items.Add(folder);lsSkinList.Items.Add(str);
}
}
lsSkinList.EndUpdate();
//let the user know it was successful// MessageBox.Show("All files added successfully!");}
}
catch (Exception ex){
//handle any errors that occurredMessageBox.Show(ex.Message);}
}
privatevoid btnRefresh_Click(object sender, EventArgs e){
try{
strCurrentDir =
"";strCurrentDir = strCurrentDir +
"\\cab";AllFilesInDirectory(strCurrentDir);
}
catch (Exception ex){
//handle any errors that occurredMessageBox.Show(ex.Message);}
}
}
}