Domanda

I'd like to save a file programmatically to all SharePoint (front-end) servers in the current Farm.

Right now I'm doing the following:

string path = String.Join("\\", SPUtility.GetVersionedGenericSetupPath("TEMPLATE\\LAYOUTS\\STYLES\\Themable", 15), "AutoGeneratedThemedImageFile.css");
File.WriteAllText(path, "foo", Encoding.UTF8);

The problem is, that this will only write to the Server where the code is currently running (which makes sense I guess).

What is the correct way to do something like this? Should I create and deploy a solution programmatically? If so how? (Couldn't find anything useful when doing a quick googleing.) Or is there another, better way?

edit: Why I need this: I generate a CSS with themed images based on some settings a (farm) admin can configure on runtime. This CSS files needs then be placed in the themable folder in the 15-hive, so that it can/will be used when applying a new composed look.

È stato utile?

Soluzione

A Timer Job can run on all servers by creating a job definition for each server on the farm.

Though that blog post is a little conflicting with the documentation where it says that having a lock type None should have it run on all servers as well.

This seems the way to go to do what you want.

Altri suggerimenti

Why you do not use WSP to deploy files?

Create new solution in VS, add SharePoint mapped folder (select folder where you want to copy the files) and there place you new files.

Deploy the solution.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top