Bonjour :
Mon but consiste à copier un fichier et le stocker dans un dossier « files » qui va être dans le package d’installation : application winforms.
J’arrives pas à donner le chemin abslue pour le copie :
System.IO.File.Copy(scanPath1, @"E:\Projets\RainaSolutions\Nouveau dossier\Courtney_v2p0p1\Courtney_v2p0p1\Files\" + "FileScan1Contract" + txtcontractID.Text + ExtScanPath1);

Comment je peux me débarraser de « @"E:\Projets\RainaSolutions\Nouveau dossier\Courtney_v2p0p1\Courtney_v2p0p1 »

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
27
28
29
30
31
32
33
34
35
 
private void lblUploadFile1_Click(object sender, EventArgs e)
        {
            /* onclick sur OpenFileDialog le label Delete deviendra invisible et le label qui contient le  
               chemin du fichier prendra la valeur string.Empty
             */
            lblDeleteFile1.Visible = false;
            lblFileScan1.Text = string.Empty;
            /* 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();
            ExtScanPath1=System.IO.Path.GetExtension(scanPath1).ToString();
            /* Test sur la validité de l'extension du fichier*/
            if ((ExtScanPath1 != ".pdf") && (ExtScanPath1 != ".doc") && (ExtScanPath1 != ".txt") && (ExtScanPath1 != ".JPEG"))
                 {
                     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))
                     {
                         string _path = Path.GetFullPath(FolderContract)+"\\";
                         System.Windows.Forms.MessageBox.Show(_path);
                         System.IO.File.Copy(scanPath1, @"E:\Projets\RainaSolutions\Nouveau dossier\Courtney_v2p0p1\Courtney_v2p0p1\Files\" + "FileScan1Contract" + txtcontractID.Text + ExtScanPath1);
                     }                    
                    lblDeleteFile1.Visible = true; 
                }                  
        }