visual studio - C# 2010 - Download File From Sharepoint Error -


i wondering if me this, i'm beginner, i'm trying use "script task" @ ssis project should download file sharepoint , save @ local folder:

using system; using system.data; using microsoft.sqlserver.dts.runtime; using system.windows.forms; using system.collections.generic; using system.text; using system.xml; using system.net; using system.configuration.assemblies; using system.io;  namespace st_3b90f3dd23cf4b25bb1e0175ac566fde.csproj {     [system.addin.addin("scriptmain", version = "1.0", publisher = "", description = "")]     public partial class scriptmain : microsoft.sqlserver.dts.tasks.scripttask.vstartscriptobjectmodelbase     {      #region vsta generated code     enum scriptresults     {         success = microsoft.sqlserver.dts.runtime.dtsexecresult.success,         failure = microsoft.sqlserver.dts.runtime.dtsexecresult.failure     };     #endregion       public void main()     {         system.net.webclient client = new system.net.webclient();          client.usedefaultcredentials = true;          string urlofthespfile = "https://sharepointlocation";         string localpathtothefile = @"c:\localfolder";         client.downloadfile(urlofthespfile, localpathtothefile);         client.dispose();          dts.taskresult = (int)scriptresults.success;     } } } 

this seemed work fine @ visual studio 2008 i'm using vs 2010 (c# 2010) , cannot running.

hope can me.

thank you!

try use @ before remotepath , try using client rather having dispose.

  var remotefile = @"https://pathtoremotefile";     var localfile = @"c:\pathtolocalfile";     using(webclient wc = new webclient())     {         wc.credentials = credentialcache.defaultnetworkcredentials;         // or new system.net.networkcredential("user","pass","domain");         wc.downloadfile(remotefile,localfile);     } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -