예제 #1
0
        public void AdaugaPoza(int id)
        {
            RestaurantEntities1 context = new RestaurantEntities1();

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.ShowDialog();
            FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, System.Convert.ToInt32(fs.Length));
            fs.Close();


            string iName  = dlg.FileName;
            string folder = @"\Image\";
            var    path   = Path.Combine(Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName, Path.GetFileName(iName));

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            context.AdaugarePoza(path, id);

            string currentFolder = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName;

            File.Copy(iName, path);
        }