Пример #1
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        uploadF up         = new uploadF();
        string  UploadFile = up.savefile(FileReUpload);

        //Get the Input File Name and Extension.
        string fileName      = Path.GetFileNameWithoutExtension(UploadFile);
        string fileExtension = Path.GetExtension(UploadFile);

        //Build the File Path for the original (input) and the encrypted (output) file.
        string input  = Server.MapPath("~/temp/") + fileName + fileExtension;
        string output = Server.MapPath("~/temp/") + fileName + "_enc" + fileExtension;

        this.Encrypt(input, output, HiddenKey.Value);

        if (DataAccess.GetInstance().ReuploadFiles_add_File(Convert.ToInt32(HiddenFileId.Value), fileName + "_enc" + fileExtension))
        {
            Utils.ShowAlertMessage("Successfully Reuploaded");
            Response.Redirect("Reupload.aspx");
        }
        else
        {
            Utils.ShowAlertMessage("Server Down Try Later");
        }

        if (input != null || input != string.Empty)
        {
            if ((System.IO.File.Exists(input)))
            {
                System.IO.File.Delete(input);
            }
        }
    }
Пример #2
0
    protected void BtnUpload_Click(object sender, EventArgs e)
    {
        string  FileName      = TxtFileName.Text.Trim();
        uploadF up            = new uploadF();
        string  UploadFile    = up.savefile(FileUp);
        string  fileName      = Path.GetFileNameWithoutExtension(UploadFile);
        string  fileExtension = Path.GetExtension(UploadFile);
        string  Key           = HiddenKey.Value;
        //Build the File Path for the original (input) and the encrypted (output) file.
        string input  = Server.MapPath("~/temp/") + fileName + fileExtension;
        string output = Server.MapPath("~/temp/") + fileName + "_enc" + fileExtension;

        //Save the Input File, Encrypt it and save the encrypted file in output path.
        FileUp.SaveAs(input);
        this.Encrypt(input, output, Key);



        string uploadFilepath = fileName + "_enc" + fileExtension;


        int flag = 0;

        if (DataAccess.GetInstance().Files_update_File(Convert.ToInt32(HiddenFID.Value), uploadFilepath))
        {
            Utils.ShowAlertMessage("File Updated Successfully");
            flag = 1;
        }
        else
        {
            Utils.ShowAlertMessage("Server Down Try Later");
        }

        if (input != null || input != string.Empty)
        {
            if ((System.IO.File.Exists(input)))
            {
                System.IO.File.Delete(input);
            }
        }
        if (flag.Equals(1))
        {
            Response.Redirect("UpdateFile.aspx");
        }
    }
Пример #3
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string  FileName      = TxtFileName.Text.Trim();
        uploadF up            = new uploadF();
        string  UploadFile    = up.savefile(FileUp);
        int     TPA           = Convert.ToInt32(DropDownTPA.SelectedValue);
        string  Key           = GetKeyGenerate(9);
        string  fileName      = Path.GetFileNameWithoutExtension(UploadFile);
        string  fileExtension = Path.GetExtension(UploadFile);

        //Build the File Path for the original (input) and the encrypted (output) file.
        string input  = Server.MapPath("~/temp/") + fileName + fileExtension;
        string output = Server.MapPath("~/temp/") + fileName + "_enc" + fileExtension;

        //Save the Input File, Encrypt it and save the encrypted file in output path.
        FileUp.SaveAs(input);
        this.Encrypt(input, output, Key);



        string uploadFilepath = fileName + "_enc" + fileExtension;


        string User = Session["Email"].ToString();

        if (DataAccess.GetInstance().Files_add_File(User, TPA, FileName, uploadFilepath, Key))
        {
            Utils.ShowAlertMessage("File Uploaded Successfully");
            TxtFileName.Text = "";
            DropDownTPA.ClearSelection();
        }
        else
        {
            Utils.ShowAlertMessage("Server Down Try Later");
        }

        if (input != null || input != string.Empty)
        {
            if ((System.IO.File.Exists(input)))
            {
                System.IO.File.Delete(input);
            }
        }
    }