Tag Info

Hot answers tagged

5

You can use the SPWeb GetFile method to retrive the SPFile located at a specified url. Try something like this: SPFile file = SPContext.Current.Web.GetFile(string.Format("{0}/{1}", x, y));


2

Very similar to above, the SPSite object does actually remember the URL it was opened with - so you don't have to give a Web name. You should be able to use something like: string url= "Full URL to File"; using (SPSite site = new SPSite(url)){ using (SPWeb web = site.OpenWeb()) { SPFile file = web.GetFile(url); SPListItem item = ...


2

Blockquote I don't like using [0] to get the SPListItem...interested in reccomendations Well, SPList.Items[0] syntax fetch ALL THE DATA from SharePoint and after - give you item by index. That's a common behavior. You might use also SPList.GetItemById or similar methods or even make a caml query against the target list w/ SPList.GetItems method. It's ...


2

This is a simple approach I have used in the past with a try/catch so maybe you could revamp for your needs: string myResponse = "whatever needs to be written to the file..."; string filename = "C:\\splogs\\" + (DateTime.Now).ToString("yyyyMMdd") + "_customlog.log"; FileStream logStream = new FileStream(@filename, FileMode.Append); ...


1

SPFileCollection is probably a bad idea. I suppose it's too coupled to the internal SharePoint storage behavior. Replace it with a simple List<SPFile>. This will be easier and works. A side not, your approach is not taking care of files in subfolders. You should write a small recursive method to get all documents : private IEnumerable<SPFile> ...


1

I dont think there is a seperate flag for this, maybe you can use BeforeProperties and AfterProperties to achieve some workaround, like checking if only the version is increased and no other field has changed, you can consider this case as overwritten, not fullprrof not the best way but maybe one of the solutions


1

MS recommends waiting 10 mins or rebooting the server. http://support.microsoft.com/kb/899709/en-us Sometimes (mostly) that won't work so try out this code. http://www.codeproject.com/Articles/93965/Force-SharePoint-Document-Unlocked-Checked-In


1

I would recomand you read this article from Waldek concerning problems revolving with web.GetFile() available at http://blog.mastykarz.nl/inconvenient-spwebgetfilestring/ and confront with your code, particularly when you passing a certain URL to the method.



Only top voted, non community-wiki answers of a minimum length are eligible