Upload files to a folder in WSS

Discussion in 'ASP .Net' started by Kannan, Mar 7, 2004.

  1. Kannan

    Kannan Guest

    Hello,
    I was trying to upload a local file on a client machine to a
    sharepoint folder using the WebClient object. This method is present
    in a client side DLL. I need to upload the document using NTLM
    authentication.

    The method does not report any errors but the document does not appear
    in the folder.

    Here are the the two code snippets that I am working on and tested

    Any help would be very appreciated.

    Thanks
    Kannan

    /*********** Using UploadData ********************/
    string uploadUrl = "http://sharepoint/sites/projectserver_102/Shared
    Documents/Forms/AllItems.aspx";

    //string uploadUrl = "http://sharepoint/sites/projectserver_102/Shared
    Documents/";

    string filePath = "C:\\Documents and Settings\\pv\\My
    Documents\\test.txt";

    FileInfo fiUploadFile = new FileInfo(filePath);
    WebClient wcUploadAgent = new WebClient();
    wcUploadAgent.Credentials = CredentialCache.DefaultCredentials;
    FileStream fs = null;
    fs = fiUploadFile.OpenRead();
    Byte[] bUploadData = new Byte[fiUploadFile.Length];
    fs.Read(bUploadData,0,bUploadData.Length);
    string sResponse1 = System.Text.Encoding.ASCII.GetString(bUploadData);
    Byte[] arrayBytes = wcUploadAgent.UploadData(uploadUrl,"POST",bUploadData);
    string sResponse = System.Text.Encoding.ASCII.GetString(arrayBytes);


    /***************** Using UploadFile ************************/
    WebClient wcUploadAgent = new WebClient();
    wcUploadAgent.Credentials = CredentialCache.DefaultCredentials;
    Byte[] responseArray = wcUploadAgent.UploadFile(uploadUrl, "POST",
    filePath);
    string sResponse = System.Text.Encoding.ASCII.GetString(responseArray);
    string returnValue = sResponse;
     
    Kannan, Mar 7, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    0
    Views:
    369
  2. Shikari Shambu
    Replies:
    2
    Views:
    491
  3. Replies:
    7
    Views:
    469
    Gabriel Genellina
    Sep 25, 2007
  4. cindy

    wss upload.aspx

    cindy, Jun 9, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    165
    cindy
    Jun 9, 2004
  5. Sven W.
    Replies:
    1
    Views:
    212
    Bob Barrows [MVP]
    Jan 20, 2008
Loading...

Share This Page