Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have one Document Library in central administration Name "Deployment List" it contains SharePoint Solutions(WSP files). now i want to add and deploy that solution using c# code it already get file and deploy it form Local drive but i want to get that file(WSP file from Document Library). I am using Timer job to deploy that solution Note : Solution are farm solution

my code is as follow :

try
{
    // It give Error below line that "File not Found"
    SPSolution solution = SPFarm.Local.Solutions.Add("http://centraladmin/Deployment List/MySolution.wsp"); 

    Collection selectedWebApps = new Collection();

    SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://localhost:80"));

    selectedWebApps.Add(webApp);

    solution.DeployLocal(true, true);
}
catch
{
}

I get "File not found" exception when i try to add the solution to the farm.

Any idea how to solve this error?

share|improve this question
    
I can't see what error you mean –  luccio Apr 20 '13 at 13:04
1  
He has it in a comment on line 3 in the code –  Robert Lindgren Apr 20 '13 at 13:35

2 Answers 2

up vote 2 down vote accepted

Well you didn't specify an error, but I am guessing it doesn't know what you are talking about when you give it that url.

When you deploy to SharePoint it expects a physical file in a physical location.

I had a similar problem trying to parse the contents of .doc files from the old 2003 Office library.

We ended up downloading the file to the filesystem, processing it, then deleting it from the filesystem. The same would work here and you would maintain the transparency you are looking for.

Download the file to the server filesystem

Deploy the file

Delete the file from the filesystem

share|improve this answer
    
Seems like a nice approach for overcoming the constraint of having to specify a physical path for the file. –  Robert Lindgren Apr 20 '13 at 13:42

Your code does not work as the Solution.Add method expects a System.IO.Path, not a Uri. You need to specify a valid Path (UNC, local path, etc.) when using Solution.Add("path").

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.