küçük oyun
Üye
- Mesajlar
- 22
Arkadaşlar c# da cd rom sürücüsünün hangi sürücü harfini kullandığını bulmam gerekiyor her bilgisayarda farklılık gösterebilir çünki
..küçük oyun' Alıntı:Arkadaşlar c# da cd rom sürücüsünün hangi sürücü harfini kullandığını bulmam gerekiyor her bilgisayarda farklılık gösterebilir çünki
using System;
using System.IO;
class Test
{
public static void Main()
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(
" Available space to current user:{0, 15} bytes",
d.AvailableFreeSpace);
Console.WriteLine(
" Total available space: {0, 15} bytes",
d.TotalFreeSpace);
Console.WriteLine(
" Total size of drive: {0, 15} bytes ",
d.TotalSize);
}
}
}
}
/*
This code produces output similar to the following:
Drive A:\
File type: Removable
Drive C:\
File type: Fixed
Volume label:
File system: FAT32
Available space to current user: 4770430976 bytes
Total available space: 4770430976 bytes
Total size of drive: 10731683840 bytes
Drive D:\
File type: Fixed
Volume label:
File system: NTFS
Available space to current user: 15114977280 bytes
Total available space: 15114977280 bytes
Total size of drive: 25958948864 bytes
Drive E:\
File type: CDRom
The actual output of this code will vary based on machine and the permissions
granted to the user executing it.
*/
..küçük oyun' Alıntı:dediğin şey sadece d sürücü harfi için sanırım d harfi bi harddisk sürücüsü ise onun harfini değiştirmezmi böyle yoksa benmi yanlış anladım
.küçük oyun' Alıntı:dostum nasıl yapıcağımı bulamadım elinde bi kod varsa çok iyi olur
..küçük oyun' Alıntı:peki dostum yinede saol
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DriveInfo[] allDrives = DriveInfo.GetDrives();
private void button1_Click(object sender, EventArgs e)
{
foreach (DriveInfo d in allDrives)
{
if (Convert.ToString(d.DriveType) == "CDRom")
{
label2.Text = d.Name;
label4.Text = d.VolumeLabel;
}
}
}
}
}
.küçük oyun' Alıntı:label2.Text = d.Name;
label4.Text = d.VolumeLabel;
bölümlerinde çalıştırıp cd rom bul diyince hata veriyo dostum sebebi nedir acaba emek harcadığın için saol![]()
..küçük oyun' Alıntı:tabiki kopyala yapıştır yapmadım verdiğin program kodlarını kendiminkine ekledim ve kullanım şeklim labela aktarılan sürücü harfini dosyanın kopyalama yapacağı yere ekledim o dediğim hatayı birkez verdi sonra almadım ayrıca tabiki ekledim using System.IO; şimdiki sorun şu programı cdden başlatıyorum dosyaları kopyala diyorum fakat hata alıyorum http://d1207.hizliresim.com/z/3/9691g.jpg
..küçük oyun' Alıntı:evet dostum tam olarak bu
static public void CopyFolder(string sourceFolder, string destFolder)
{
if (!Directory.Exists(destFolder))
Directory.CreateDirectory(destFolder);
string[] files = Directory.GetFiles(sourceFolder);
foreach (string file in files)
{
string name = Path.GetFileName(file);
string dest = Path.Combine(destFolder, name);
File.Copy(file, dest);
}
string[] folders = Directory.GetDirectories(sourceFolder);
foreach (string folder in folders)
{
string name = Path.GetFileName(folder);
string dest = Path.Combine(destFolder, name);
CopyFolder(folder, dest);
}
}