Salut tout le monde
J’ai un problème avec l’opérateur or (||)
Dans mon application je récupère l’extesion d’un fichier et après je fais les test.
Si il est diffrents de .pdf / .doc / .bat / .txt alors à ce moment un message d’erreur s’affiche, le problème c’est mêm si le fichier a une extension valide le message s’affiche :
if ((ExtScanPath1 != ".pdf") ||((ExtScanPath1 != ".doc") ||((ExtScanPath1 != ".txt") )
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
22
23
24
25
26
 
/* Ouverture de OpenFileDialog*/
            OpenFileDialog OFD = new OpenFileDialog();
            OFD.ShowDialog();
 
            /* Récupération du chemin du fichier ainsi que son extension*/
            string scanPath1 = OFD.FileName.ToString();
            string ExtScanPath1=System.IO.Path.GetExtension(scanPath1).ToString(); 
 
            /* Test sur la validité de l'extension du fichier*/
            if ((ExtScanPath1 != ".pdf") ||((ExtScanPath1 != ".doc") )
                 {
                     System.Windows.Forms.MessageBox.Show("This File is invalid");   
                 }           
            else
                 {
                     /* Lancement du fichier pour visualisation */
                     Process.Start(scanPath1);
                     lblFileScan1.Text = scanPath1;
                     /* test de l'existence du fichier et upload */
                     if (System.IO.File.Exists(scanPath1))
                     {
                         System.IO.File.Copy(scanPath1,@"E:\Projets\RainaSolutions\Nouveau dossier\Courtney_v2p0p1\Courtney_v2p0p1\Files\" + "FileScan1Contract" + txtcontractID.Text + ".pdf");
                     }                    
                    lblDeleteFile1.Visible = true; 
                }