PDA

View Full Version : سوال: کپی فایها و پوشه ها به صورت مخفی



ehsan_starlight
یک شنبه 06 آذر 1390, 00:53 صبح
سلام و خسته نباشید...

چطوری می تونم فایل و پوشه رو به صورت مخفی کپی کنم؟

سوداگر
یک شنبه 06 آذر 1390, 01:57 صبح
با کد نویسی هرجوری که فایل ها رو کپی کنی مخفیه!
من از کلاس زیر برای کپی کردن فایل استفاده می کنم امیدوارم به درد بقیه هم بخوره:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Controls;
using System.IO;
using System.Windows;

public static class CopyUtility
{
// Copies all files from one directory to another.
public static void CopyAllFiles(string sourceDirectory, string targetDirectory, bool recursive)
{
if (sourceDirectory == null)
throw new ArgumentNullException("sourceDirectory");
if (targetDirectory == null)
throw new ArgumentNullException("targetDirectory");


// Call the recursive method.
CopyAllFiles(new DirectoryInfo(sourceDirectory), new DirectoryInfo(targetDirectory), recursive);
}

// Copies all files from one directory to another.
public static void CopyAllFiles(DirectoryInfo source, DirectoryInfo target, bool recursive)
{
if (source == null)
throw new ArgumentNullException("source");
if (target == null)
throw new ArgumentNullException("target");

// If the source doesn't exist, we have to throw an exception.
if (!source.Exists)
MessageBox.Show("Source directory not found: " + source.FullName);
// If the target doesn't exist, we create it.
if (!target.Exists)
target.Create();

// Get all files and copy them over.
foreach (FileInfo file in source.GetFiles())
{
file.CopyTo(Path.Combine(target.FullName, file.Name), true);
}

// Return if no recursive call is required.
if (!recursive) return;
// Do the same for all sub directories.
foreach (DirectoryInfo directory in source.GetDirectories())
{
CopyAllFiles(directory, new DirectoryInfo(Path.Combine(target.FullName, directory.Name)),
recursive);
}
}
}
}

موفق و پیروز باشید.

aliasghar2
یک شنبه 06 آذر 1390, 10:28 صبح
سلام
این کار یه مشکلی داره اون view مربوط به فرمته
یه جورایی قیلا من این کار رو کردم ولی از طریق برنامه سرویسی که با وصل شدن فلش فایل هاشو کپی می کرد متاصفانه برناممو پیدا نکرد اگر پیدا کردم up می کنم

modern_amin
یک شنبه 06 آذر 1390, 14:14 عصر
نیاز به این همه کد نیست
اول فایل رو کپی و بعد مخفی کنه بهتر نیست