Bir sürü resminiz var, yazıcıdan taradınız bitmap olarak ama herbirinin boyutu en az 5-10 mb arası, hepsini birden resize etmek istiyorsunuz baktınız programda bulamadınız o zaman kendi kodunuzu kendiniz yazacaksınız demektir, aşağıdaki örnekte c:\taradıklarım klasöründeki resimleri d:\taradıklarım isimli klasöre taşıyan ve jpg olarak kaydeden bir örnek görüyorsunuz. Resimlerin boyutu 100-200 kb civarına düşecektir.
static void Main(string[] args)
{
Bitmap img;
try
{
string filePath = @"c:\taradıklarım\";
string[] files = Directory.GetFiles(filePath, "*.bmp");
foreach (string imagename in files)
{
img = new System.Drawing.Bitmap(imagename);
using (img)
{
int w = (int)(img.Width * 800 / img.Width);
int h = (int)(img.Height * 800 / img.Width);
try
{
using (Image thumb = new Bitmap(w, h, PixelFormat.Format24bppRgb))
{
using (Graphics g = Graphics.FromImage(thumb))
{
g.DrawImage(img
, new System.Drawing.Rectangle(0, 0, w, h)
, new System.Drawing.Rectangle(0, 0, img.Width, img.Height)
, System.Drawing.GraphicsUnit.Pixel);
}
thumb.Save(imagename.Replace("c:","d:").Replace(".bmp",".jpg"), ImageFormat.Jpeg);
}
}
catch (Exception x)
{
}
}
}
}
catch (Exception x)
{
}
}
Abdullahkuzhan.com gibi bir siteniz olduğunu düşünün. VDirectory1 isimli bir Application veya Virtual Folder yaratmak istediğinizi varsayacak olursak aşağıdaki kodu kullanabilirsiniz. Hosting firmaları tarafından verilen panellerde arayüzler ile otomatik oluşturduğunuz Virtual’lar kod ile aşağıdaki gibi oluşturulabilir. Bunu zamanında 50+ Virtual’ı olan bir siteyi bir başka makineye taşırken yazmıştım(IIS’te taşınabilir tabiki).
string strSchema = "IIsWebVirtualDir";
string strRootSubPath = "/W3SVC/1/Root";
DirectoryEntry deRoot = new DirectoryEntry("IIS://" + "localhost" + strRootSubPath);
try
{
deRoot.RefreshCache();
DirectoryEntry deNewVDir = deRoot.Children.Add("AbdullahKuzhan.com/"+"VDirectory1", strSchema);
deNewVDir.Properties["Path"].Insert(0, "d:\sites\abdullahkuzhan.com\MyFolder\");
deNewVDir.CommitChanges();
deRoot.CommitChanges();
if (strSchema == "IIsWebVirtualDir")
deNewVDir.Invoke("Create", true); // "AppCreate" dersen application olarak yaratır, "Create" dersen virtual folder olarak yaratır.
deNewVDir.CommitChanges();
deRoot.CommitChanges();
deNewVDir.Close();
deRoot.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
int? a =null;
bu şekilde int değişkene null değer atanabilir.
follow: