4

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.

2
  • Themes is a library in SP 2013 and it has the 15 folder, if you copy your css files to it then it gets copied to the site and is available from all servers.
    – Manu
    Commented Jan 27, 2015 at 16:07
  • Hi I think only "applied" themes (e.g. themed images and so on) are in a library - or not? My file however is needed to theme certain images when applying a composed look. ...
    – OschtärEi
    Commented Jan 27, 2015 at 18:20

2 Answers 2

1

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.

0
0

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.

2
  • I think you misunderstood the question. I know you can do that - but this doesn't help me. In my case the css will change on run time - manually deploy (and only "one time deploy") a soution won't help me.
    – OschtärEi
    Commented Jan 27, 2015 at 18:18
  • Oh, ok...then place CSS in the Style library inside the SP Site where you can easily modify it.
    – luccio
    Commented Jan 28, 2015 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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