Monthly Archives: January 2005

Check if a file exists on a remote web server (by http)

using System.Net; WebRequest wrq = WebRequest.Create_ ("Http://www.example.com/fileToTest.htm"); bool fileExists = false; try { WebResponse wrs = wrq.GetResponse(); fileExists = true; } catch { }

Posted in C# Snippets | Comments Off

Get SharePoints Database names and connection strings.

C Sharp source code for grabbing database details in sharepoint Using Sharepoint’s internal mechanisms, it is possible to retrieve the database name and connection string for the content databases that power a site. The code in the attached file uses … Continue reading

Posted in C# Snippets | Comments Off

Conditional methods

To create methods that will only be called in a debug build of your application, you can use the following syntax : [Conditional( "DEBUG" )] private void SetDebugVariables() { connect ionString = “datasource=developmentDB;SSPI=true;initial catalog=development”; Trace.WriteLine(“Called in debug build”); } One … Continue reading

Posted in C# Snippets | Comments Off