You must Sign In to post a response.
  • Category: Sharepoint

    File upload validation this file name already available in file in sharepoint 2010

    file upload validation this file name already available in file in sharepoint 2010

    uoload same file name into document library in sharepoint 2010.given error massage in sharepoint c# code
  • #730332
    Hi viswanathreddy,

    The error message clearly suggests you that you are trying to loaded file that file already available in that List / Library. Please check and rename that file then load again.


    Hope this will help you..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #730334

    hey,

    please upload another file your error removed.
    you upload same filename which is already in your datbase

    Thanks;
    ketan

  • #730336
    Hi Naveen,

    i have upload document into document library using grammatically when upload at that time i want error this file name already available in document can you change name

  • #730338
    please upload another file your error removed.
    you upload same filename which is already in your datbase

    same but i want code in sharepoint 2010 c#

  • #730343
    Hi viswanathreddy,

    I didn't get you what you are exactly expecting, based on your error description you try to upload same file which is available in your List / Document Library. Try to load different file.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #730350

    private void AttachFile(FileUpload fuAttachmentControl, CheckBoxList chk, Button btnR)
    {
    try
    {
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
    if (fuAttachmentControl.HasFile)
    {
    if (fuAttachmentControl.PostedFile != null && fuAttachmentControl.HasFile)
    {
    string fileName = Path.GetFileName(fuAttachmentControl.PostedFile.FileName);

    bool exitornot = CheckToDuplicate(fileName);//Modified by prabhakar
    if (exitornot)//Modified by prabhakar
    Page.ClientScript.RegisterClientScriptBlock(typeof(SPAlert), "alert", "<script language=\"javascript\">alert('The Attachment " + fileName + " already exists.Please select different file')</script>");
    else
    {
    string tempFilePath = "";
    if (!fileName.Contains("@"))
    {
    tempFilePath = System.IO.Path.GetTempPath().ToString() + "\\" + fuAttachmentControl.FileName;
    fuAttachmentControl.SaveAs(tempFilePath);
    if (hfFiles.Value == "")
    {
    hfFiles.Value = tempFilePath;
    hfFileNames.Value = fuAttachmentControl.FileName;
    }
    else
    {
    hfFiles.Value = hfFiles.Value + "@" + tempFilePath;
    hfFileNames.Value = hfFileNames.Value + "@" + fuAttachmentControl.FileName;
    }

    string[] attachedfiles = hfFiles.Value.Split('@');
    string[] attachedfileNames = hfFileNames.Value.Split('@');

    DataTable dtFiles = new DataTable();
    dtFiles.Columns.Add("FileName");
    dtFiles.Columns.Add("FilePath");

    for (int i = 0; i < attachedfiles.Length; i++)
    {
    dtFiles.Rows.Add(attachedfileNames[i], attachedfiles[i]);
    }
    chk.Visible = true;
    chk.DataSource = null;
    chk.DataSource = dtFiles;
    chk.DataValueField = "FilePath";
    chk.DataTextField = "FileName";
    chk.DataBind();

    if (dtFiles.Rows.Count > 0)
    btnR.Visible = true;
    else
    btnR.Visible = false;
    }
    }
    }
    }
    });
    }
    catch (Exception ex)
    {
    Page.ClientScript.RegisterClientScriptBlock(typeof(SPAlert), "alert", "<script language=\"javascript\">alert('" + ex.Message + "')</script>");
    }
    }

    public bool CheckToDuplicate(string fileName)
    {
    foreach (string file in hfFileNames.Value.Split('@'))
    {
    if (fileName == file)
    return true;
    }
    return false;
    }


  • Sign In to post your comments