Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Monday, February 14, 2011

To Hide a file in C#

Hi this is a basic sample shows how to create and hide a Directory in C#

image

Wednesday, May 19, 2010

How to clear the temp folder in windows start up using C#

 

Today i decided to create an application using C# which clears the temp folder when ever windows startup.So no need to clear your temp file always.

Here is the code what i have tried:

RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
regKey.SetValue(Application.ProductName, Application.ExecutablePath);

string path = Path.GetTempPath();
if (!string.IsNullOrWhiteSpace (path))
{
DirectoryInfo d = new DirectoryInfo(path);
Array.ForEach(Directory.GetFiles(path), s =>
{ try { label1.Text = s; File.Delete(s); } catch (Exception ex) { } });
label1.Text = "Done";
}

If any exception will come it wont show that exception,it will proceed from the next


If put the application in "Software\Microsoft\Windows\CurrentVersion\Run" when ever the windows starts it automatically runs.

Tuesday, May 18, 2010

Twitter API in C#

 

Today i have seen a thread in my favorite site Stackoverflow on Twitter. So i decided to create a small Twitter API WCF application.

Twitter is designed on REST architecture. Here is a sample code to integrate the Twitter in C#.

Download the TweetSharp

To Authenticate user in the Twitter:

ITwitterLeafNode twitter =FluentTwitter.CreateRequest()
.AuthenticateAs(StaticProperties.Username, StaticProperties.Password)
.Account().VerifyCredentials().AsJson();

if (twitter.Request().ResponseHttpStatusDescription == "OK")
{
}

To Update new Tweet:



ITwitterLeafNode twitter =FluentTwitter.CreateRequest()
.AuthenticateAs(StaticProperties.Username,StaticProperties.Password)
.Statuses().Update("Hello World).AsJson();
var request = twitter.Request();

Note: By using this API you will get all the Twitter related things,Like all Followers,To ReTweet etc.
 
Counter