コード例 #1
0
ファイル: mydb.cs プロジェクト: nassimbendaou/FileManager
        public void Chargerlesfichierdsd(Utulisateur user, Dossier directory)
        {
            fichier d;
            string  smt = "SELECT nom,proprietair,emplacement,format,droitacces,datecreation,blob,id FROM dbo.Fichier Where proprietair=@owner and  emplacement=@parent ";

            cmd = new SqlCommand(smt, conn);
            cmd.Parameters.AddWithValue("@owner", user.GetNom());
            cmd.Parameters.AddWithValue("@parent", directory.Getid());
            SqlDataReader rs = cmd.ExecuteReader();

            while (rs.Read())
            {
                if (rs.IsDBNull(6))
                {
                    d = new fichier(rs.GetString(0), rs.GetString(3), user, directory, rs.GetInt32(7));
                }
                else
                {
                    byte[] byteData = (byte[])rs[6];
                    d = new fichier(rs.GetString(0), rs.GetString(3), user, directory, byteData);
                }
                directory.Setlistfichier(d);
            }
            rs.Close();
        }
コード例 #2
0
        public ActionResult AddPhoto(fichier model, int id)
        {
            string rep = @"C:\Inetpub\vhosts\default\htdocs\Content\image\";

            if (model.File != null && model.File.ContentLength > 0)
            {
                string[] ext      = new string[] { "jpg", "jpeg", "png", "gif" };
                string   path     = "";
                bool     trouve   = false;
                int      i        = 0;
                string   nomPhoto = Path.GetFileName(model.File.FileName);
                int      index    = nomPhoto.LastIndexOf('.');
                string   newName  = nomPhoto.Substring(index);
                newName = id + newName;
                do
                {
                    path = id + "." + ext[i];
                    if (System.IO.File.Exists(@"C:\Inetpub\vhosts\default\htdocs\Content\image\" + path))
                    {
                        System.IO.File.Delete(@"C:\Inetpub\vhosts\default\htdocs\Content\image\" + path);
                    }
                    i++;
                } while (!trouve && i < ext.Length);
                model.File.SaveAs(Path.Combine(rep, newName));
            }
            return(RedirectToAction("/Joueur/" + id));
        }
コード例 #3
0
 public Texteditor(fichier f)
 {
     InitializeComponent();
     file = f;
     if (f.GetBlob() != null)
     {
         richTextBox1.Text = f.BinaryToText(f.GetBlob());
         oldtext           = richTextBox1.Text;
     }
 }
コード例 #4
0
ファイル: mydb.cs プロジェクト: nassimbendaou/FileManager
        public void insertfilblob(fichier file)
        {
            string smt = "UPDATE Fichier SET blob = @blob  WHERE id = @id;";

            cmd = new SqlCommand(smt, conn);
            cmd.Parameters.AddWithValue("@blob", file.GetBlob());
            cmd.Parameters.AddWithValue("@id", file.Getid());


            cmd.ExecuteNonQuery();
        }
コード例 #5
0
ファイル: mydb.cs プロジェクト: nassimbendaou/FileManager
        public void Chargerlesfichierofuser(Utulisateur user)
        {
            Dossier dir = new Dossier();
            string  smt = "SELECT nom,proprietair,emplacement,format,droitacces,datecreation,id FROM dbo.Fichier Where proprietair=@owner and  emplacement =-1";

            cmd = new SqlCommand(smt, conn);
            cmd.Parameters.AddWithValue("@owner", user.GetNom());

            SqlDataReader rs = cmd.ExecuteReader();

            while (rs.Read())
            {
                fichier d = new fichier(rs.GetString(0), rs.GetString(3), user, null, rs.GetInt32(6));
                user.Setlistfiles(d);
            }
            rs.Close();
        }
コード例 #6
0
ファイル: mydb.cs プロジェクト: nassimbendaou/FileManager
        public void chargerblob(fichier file)
        {
            string smt = "SELECT blob FROM dbo.Fichier Where nom=@Name";

            cmd = new SqlCommand(smt, conn);
            cmd.Parameters.AddWithValue("@Name", file.GetNom());
            SqlDataReader rs = cmd.ExecuteReader();

            while (rs.Read())
            {
                if (DBNull.Value != rs[0])
                {
                    byte[] byteData = (byte[])rs[0];
                    file.Setblob(byteData);
                }
            }
            rs.Close();
        }
コード例 #7
0
        public Proprety(fichier f, Dossier d)
        {
            InitializeComponent();
            int size;

            if (f != null && d == null)
            {
                pictureBox1.BackgroundImage = imageList1.Images[1];
                textBox1.Text = f.GetNom().Trim() + "." + f.GetFormat().Trim();
                label4.Text   = f.GetFormat();

                if (f.GetBlob() != null)
                {
                    size = f.GetBlob().Length;
                }
                else
                {
                    size = 0;
                }

                label5.Text = size.ToString() + " Octets";
                label3.Text = null;
                label6.Text = null;
                label8.Text = f.GetDatecreation().ToString();
            }
            if (d != null && f == null)
            {
                pictureBox1.BackgroundImage = imageList1.Images[0];
                textBox1.Text = d.GetNom().Trim();
                label4.Text   = "Dossier";
                size          = d.Getlistoffiles().Count + d.Getlistofdir().Count;
                label5.Text   = size.ToString();
                label3.Text   = "Contains : ";
                label6.Text   = d.Getlistoffiles().Count + " files," + d.Getlistofdir().Count + " directorys";
                label8.Text   = d.GetDatecreation().ToString();
            }
        }
コード例 #8
0
 public void Setlistfiles(fichier user) => listfiles.Add(user);