15 Mayıs 2015 Cuma

c# Taskbar gizleme kodu

c# ile alt barı gizleyebilirsiniz.Taskbar gizleme hide işlemi için kodlar...
using System; using System.Runtime.InteropServices; public static class Taskbar { [DllImport("user32.dll")] private static extern int FindWindow(string className, string windowText); [DllImport("user32.dll")] private static extern int ShowWindow(int hwnd, int command); [DllImport("user32.dll")] public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle); [DllImport("user32.dll")] private static extern int GetDesktopWindow(); private const int SW_HIDE = 0; private const int SW_SHOW = 1; protected static int Handle { get { return FindWindow("Shell_TrayWnd", ""); } } protected static int HandleOfStartButton { get { int handleOfDesktop = GetDesktopWindow(); int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0); return handleOfStartButton; } } public static void Show() { ShowWindow(Handle, SW_SHOW); ShowWindow(HandleOfStartButton, SW_SHOW); } public static void Hide() { ShowWindow(Handle, SW_HIDE); ShowWindow(HandleOfStartButton, SW_HIDE); } }

10 Mayıs 2015 Pazar

C# dizin kopyalama işlemi

  string sourcePath = @"C:\Users\Public\TestFolder";
        string targetPath =  @"C:\Users\Public\TestFolder\SubDir";
if (System.IO.Directory.Exists(sourcePath))
        {
            string[] files = System.IO.Directory.GetFiles(sourcePath);

            foreach (string s in files)
            {
                fileName = System.IO.Path.GetFileName(s);
                destFile = System.IO.Path.Combine(targetPath, fileName);
                System.IO.File.Copy(s, destFile, true);
            }
        }

C# açık olan dosyaları kopyalama

using(var inputFile = new FileStream(
         "oldFile.txt", 
         FileMode.Open, 
         FileAccess.Read, 
         FileShare.ReadWrite))
     {
        using (var outputFile = new FileStream("newFile.txt", FileMode.Create))
        { 
            var buffer = new byte[0x10000];
            int bytes;

            while ((bytes = inputFile.Read(buffer, 0, buffer.Length)) > 0) 
            {
                outputFile.Write(buffer, 0, bytes);
            }
        }
    }