示例#1
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            var filename = Path.GetFileName(fileUpload1.PostedFile.FileName);

            var getExts = Path.GetExtension(filename);

            var str = fileUpload1.PostedFile.InputStream;
            var br = new BinaryReader(str);
            var size = br.ReadBytes((int) str.Length);

            using (var obj = new ROPAEntities())
            {
                var upld = new UploadFile();
                upld.GUID = Guid.NewGuid().ToString();
                upld.AppVersion = (decimal) 2.30;

                upld.FIleFor = filename;
                upld.SurApp_Id = 47;
                upld.fileext = getExts;

                obj.AddToUploadFiles(upld);
                obj.SaveChanges();
            }
            BindGridviewData();
        }
        catch (Exception)
        {

        }
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);

        Stream stream = fileUpload1.PostedFile.InputStream;

        string extension = Path.GetExtension(filename);
        //Write Save Logic  to file/
        BinaryReader br = new BinaryReader(stream);
        Byte[] size = br.ReadBytes((int)stream.Length);
        //SaveToFolder(stream, filename);

        //Database already here
        List<UploadFile> L = ResolveList();
        using (ROPAEntities obj = new ROPAEntities())
        {
            Guid G = Guid.NewGuid();
            UploadFile upld = new UploadFile();
            upld.GUID = G.ToString();
            upld.FIleFor = filename;
            upld.SurApp_Id = null;
            obj.AddToUploadFiles(upld);
            obj.SaveChanges();

            L.Add(upld);
        }
        UpdateSession(L);
        BindGridviewData();
    }
示例#3
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);

        string GetExts = Path.GetExtension(filename);

        Stream str = fileUpload1.PostedFile.InputStream;
        BinaryReader br = new BinaryReader(str);
        Byte[] size = br.ReadBytes((int)str.Length);

        using (ROPAEntities obj = new ROPAEntities())
        {
            UploadFile upld = new UploadFile();

            upld.GUID = Guid.NewGuid().ToString();
            //upld.FIleFor=100;
            upld.FIleFor = filename;
            upld.SurApp_Id = 47;
            upld.fileext = GetExts;

            obj.AddToUploadFiles(upld);
            obj.SaveChanges();
        }
        BindGridviewData();
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string filename = Path.GetFileName(fileUpload1.PostedFile.FileName);

        Stream stream = fileUpload1.PostedFile.InputStream;

        int fileSize = fileUpload1.PostedFile.ContentLength;

        string extension = Path.GetExtension(filename);
        //Write Save Logic  to file/
        BinaryReader br = new BinaryReader(stream);
        Byte[] size = br.ReadBytes((int)stream.Length);
        //SaveToFolder(stream, filename);

        //Database already here
        List<UploadFile> L = ResolveList();

        if (L.Count > 0)
        {
            //If file is Already Exist or not if exist skip this step
            bool flag;
            flag = IsFileExistOrNot(L, filename);
            if (IsFileExistOrNot(L, filename) == false)
            {
                using (ROPAEntities obj = new ROPAEntities())
                {
                    Guid G = Guid.NewGuid();
                    UploadFile upld = new UploadFile();
                    upld.GUID = G.ToString();
                    upld.FIleFor = filename;
                    upld.SurApp_Id = null;
                    upld.filecc = size;
                    obj.AddToUploadFiles(upld);
                    obj.SaveChanges();

                    L.Add(upld);
                }
                UpdateSession(L);
                BindGridviewData();
            }
        }
        else
        {
            //Not there here  first time
            using (ROPAEntities obj = new ROPAEntities())
            {
                Guid G = Guid.NewGuid();
                UploadFile upld = new UploadFile();
                upld.GUID = G.ToString();
                upld.FIleFor = filename;
                upld.filecc = size;
                obj.AddToUploadFiles(upld);
                obj.SaveChanges();
                L.Add(upld);
            }
            UpdateSession(L);
            BindGridviewData();
        }
    }