Blog Home  Home Feed your aggregator (RSS 2.0)  
kevin Mocha - Tuesday, November 11, 2008
Bookmarks collected from web.
 
 Tuesday, November 11, 2008

http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1255498,00.html

         public static void GenerateRsa(string privateKeyPath, string publicKeyPath, int size)
        {
            //stream to save the keys
            FileStream fs = null;
            StreamWriter sw = null;

            //create RSA provider
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(size);
            try
            {
                //save private key
                fs = new FileStream(privateKeyPath, FileMode.Create, FileAccess.Write);
                sw = new StreamWriter(fs);
                sw.Write(rsa.ToXmlString(true));
                sw.Flush();
            }
            finally
            {
                if (sw != null) sw.Close();
                if (fs != null) fs.Close();
            }

            try
            {
                //save public key
                fs = new FileStream(publicKeyPath, FileMode.Create, FileAccess.Write);
                sw = new StreamWriter(fs);
                sw.Write(rsa.ToXmlString(false));
                sw.Flush();
            }
            finally
            {
                if (sw != null) sw.Close();
                if (fs != null) fs.Close();
            }
            rsa.Clear();
        }
Tuesday, November 11, 2008 6:00:16 PM UTC  #    Comments [1]    |  Trackback
 Friday, November 07, 2008

http://msdn.microsoft.com/en-us/ms741997(VS.85).aspx

        // Begins the storyboard.
        private void beginButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Specifying "true" as the second Begin parameter
            // makes this storyboard controllable.
            myStoryboard.Begin(this, true);          
        
        }
        
        // Pauses the storyboard.
        private void pauseButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Pause(this);          
        
        }
        
        // Resumes the storyboard.
        private void resumeButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Resume(this);          
        
        }     
        
        // Advances the storyboard to its fill period.
        private void skipToFillButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.SkipToFill(this);          
        
        } 
        
        // Updates the storyboard's speed.
        private void setSpeedRatioButton_Clicked(object sender, RoutedEventArgs args)
        {
            // Makes the storyboard progress three times as fast as normal.
            myStoryboard.SetSpeedRatio(this, 3);          
        
        }           
        
        // Stops the storyboard.
        private void stopButton_Clicked(object sender, RoutedEventArgs args)
        {
             myStoryboard.Stop(this);          
        
        }         
Friday, November 07, 2008 3:48:14 PM UTC  #    Comments [0]    |  Trackback
 Friday, October 17, 2008
ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
// Redirect both streams so we can write/read them.
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
// Start the procses.
Process p = Process.Start(si);
// Issue the dir command.
p.StandardInput.WriteLine(@"dir c:");
// Exit the application.
p.StandardInput.WriteLine(@"exit");
// Read all the output generated from it.
string output = p.StandardOutput.ReadToEnd();
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ShellCommandsInCS12032005042031AM/ShellCommandsInCS.aspx
Friday, October 17, 2008 5:55:22 PM UTC  #    Comments [0]    |  Trackback

To access the console session, do this:
start | run - mstsc -v:0.0.0.0 /f -console
(replace the 0.0.0.0 with your ipaddress)

Friday, October 17, 2008 3:13:13 PM UTC  #    Comments [0]    |  Trackback
 Thursday, October 16, 2008

http://www.dotnetinterop.com/faq/?q=LoadLibrary

You can load the DLL manually before the CLR tries to do it for you, using the LoadLibrary Win32 API. By passing it the fully qualified path, you can bypass the regular search path rules.

The following code calls the exported function MyFunc in unmanaged.dll, located in the ..\unmanaged directory relative to the executable.

C#

[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);

[DllImport("unmanaged.dll")]
static extern int MyFunc(int i);

static void Main()
{
  // Ensure current directory is exe directory
  Environment.CurrentDirectory = Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location );

  string dllPath = Path.GetFullPath( @"..\unmanaged\unmanaged.dll" );
  LoadLibrary( dllPath );
  Console.WriteLine( MyFunc( 5 ) );
} 
 

VB.NET

Declare Auto Function LoadLibrary Lib "kernel32.dll" (ByVal lpFileName As String) As IntPtr

Declare Function MyFunc Lib "unmanaged.dll" (ByVal i As Integer) As Integer

Shared Sub Main()
  ' Ensure current directory is exe directory
  Environment.CurrentDirectory = Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)

  Dim dllPath As String = Path.GetFullPath("..\unmanaged\unmanaged.dll")
  LoadLibrary(dllPath)
  Console.WriteLine(MyFunc(5))
End Sub
    
Thursday, October 16, 2008 5:49:35 PM UTC  #    Comments [0]    |  Trackback
 Friday, October 10, 2008

1. Select the directory.

2. In the top buttons, choose "Show all files"

3. Select the directory again and choose "include in project"

4. you can choose "refresh" button on the top to update the content in the directory, and then add those new added items again.

Friday, October 10, 2008 6:30:05 PM UTC  #    Comments [0]    |  Trackback
 Wednesday, September 17, 2008
 Tuesday, September 16, 2008
 Friday, September 12, 2008

http://social.msdn.microsoft.com/forums/en-US/regexp/thread/601788d2-6958-4bd7-8c40-6fa14b8a6d84/

string resultString = Regex.Replace(input, "<a[^>]+>([^<]+)</a>", "$1");

For John Tesh Radio show mp3 downloading page: "<a[^>]+(...........\.mp3)[^>]+>([^<\(]+)</a>"

Friday, September 12, 2008 7:55:02 PM UTC  #    Comments [0]    |  Trackback
Copyright © 2009 Kevin Mocha. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: