19
2015
11

unable to open database file 写入SQLite数据库失败

 

在 Windows Server 2008 64位系统IIS 部署了一个网站程序,用到了SQLite数据库, 把应用程序池设为32位后还是不能吸入数据库数据, 错误为 “unable to open database file”


解决方法为需要给 SQLite 数据库文件所在的上一级目录添加everyone 可读可写的用户权限。

13
2015
11

VMware Workstation 虚拟机上安装Win7 Ghost

 


1.新建虚拟机,选择WIN7 的ISO 文件



2.里面一般带的都有硬盘分区工具,对硬盘分区

3.开机画面 按Esc 设置BIOS ,设置成从CS 启动

09
2015
11

Silverlight 中 Color Brush 和 string 相互之间的转换 

 

1、String转换成Color

            Color color = (Color)ColorConverter.ConvertFromString(string);

2、String转换成Brush

            BrushConverter brushConverter = new BrushConverter();
            Brush brush = (Brush)brushConverter.ConvertFromString(string);

09
2015
11

Silverlight 中颜色和字符的互相转化

 

     public static Color ToColor(string colorName)
        {
            if (colorName.StartsWith("#"))
                colorName = colorName.Replace("#", string.Empty);
            int v = int.Parse(colorName, System.Globalization.NumberStyles.HexNumber);
            return new Color()
            {
                A = Convert.ToByte((v >> 24) & 255),
                R = Convert.ToByte((v >> 16) & 255),
                G = Convert.ToByte((v >> 8) & 255),
                B = Convert.ToByte((v >> 0) & 255)
            };
        }

24
2015
10

“System.BadImageFormatException”类型的未经处理的异常在 System.Windows.Forms.dll 中发生

 “System.BadImageFormatException”类型的未经处理的异常在 System.Windows.Forms.dll 中发生



C#调用VC dll 出现“System.BadImageFormatException”,编写vc dll时用的是x86平台,即32位,而编译C#时用的x64, 即64位

将C#切换到x86平台编译,编译通过

20
2015
10

C# 获取插入的U盘的盘符信息

 

using System.IO;

 

DriveInfo[] allDrives = DriveInfo.GetDrives();

foreach (DriveInfo d in allDrives)
{
    Console.WriteLine("Drive {0}", d.Name);
    Console.WriteLine("  File type: {0}", d.DriveType);
}

16
2015
10

telerik 的 RadDiagram控件 铅笔和钢笔工具默认不填充形状内的背景色

 

 

用铅笔和钢笔工具画图的时候, 形状默认会填充颜色, 如果是画形状还好,如果是画线的话就没必要填充颜色了, 设置如下:

 

首先要引用

xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Diagrams.Primitives;assembly=Telerik.Windows.Controls.Diagrams"

 

16
2015
10

Crop that pdf page horizontaly into 4 pieces and create a new pdf for each piece

 

  

Crop that pdf page horizontaly into 4 pieces and create a new pdf for each piece


 

Document document = new Document("D:\\AP Data\\copy.pdf");
 
//Create the Copy of the page
document.Pages.Insert(2, document.Pages[1]);
document.Pages.Insert(3, document.Pages[1]);
document.Pages.Insert(4, document.Pages[1]);
 
double segment = (document.Pages[1].Rect.Height / 4);
double half = (document.Pages[1].Rect.Height / 2);
double width = document.Pages[1].Rect.Width;
double height = document.Pages[1].Rect.Height;
 
//Create Crops
Aspose.Pdf.Rectangle pageRect = new Aspose.Pdf.Rectangle(0,  height - segment,width , height);
document.Pages[1].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, height - half, width, height - segment);
document.Pages[2].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, height - half, width, (height - half) - segment);
document.Pages[3].CropBox = pageRect;
 
pageRect = new Aspose.Pdf.Rectangle(0, 0, width, half - segment);
document.Pages[4].CropBox = pageRect;
 
document.Save("D:\\AP Data\\test_Crop.pdf");

16
2015
10

Crop Pdf from each edge

 

public void TrimPdf(string sourceFilePath, string outputFilePath)
  {
        PdfReader pdfReader = new PdfReader(sourceFilePath);
        float widthTo_Trim =         iTextSharp.text.Utilities.MillimetersToPoints(5);

16
2015
10

C# Crop PDF File

 

   static void cropiTxtSharp()
   {
        string file ="C:\\testpdf.pdf";
        string oldchar = "testpdf.pdf";
        string repChar = "test.pdf";
        PdfReader reader = new PdfReader(file);
        PdfDictionary pageDict;
        PdfRectangle rect = new PdfRectangle(0, 1000, 600, 115);
        pageDict = reader.GetPageN(1);
        pageDict.Put(PdfName.CROPBOX, rect);
        PdfStamper stamper = new PdfStamper(reader, new FileStream(file.Replace(oldchar, repChar), FileMode.Create, FileAccess.Write));
        stamper.Close();
        reader.Close();
    }