private void btnInstall_Click(object sender, EventArgs e) { string workDir = AppDomain.CurrentDomain.BaseDirectory + "/installer_tmp/"; if (Directory.Exists(workDir)) Directory.CreateDirectory(workDir); FileStream fs = new FileStream(Application.ExecutablePath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader reader = new BinaryReader(fs); MessageBox.Show("exeLength:" + fs.Length); fs.Position = fs.Length - 20 + 7; int exeLength = int.Parse(reader.ReadString()); MessageBox.Show("exe Length:" + exeLength); long start = exeLength; MessageBox.Show("start : " + start); fs.Position = start; MessageBox.Show("position" + fs.Position); string instruction = reader.ReadString(); MessageBox.Show("instruction : " + instruction); File.WriteAllText(workDir + "instruction.tmp", instruction); string config = reader.ReadString(); MessageBox.Show("config:" + config); File.WriteAllText(workDir + "config.tmp", config); this.txtDescription.Text = instruction; Whats.Core.INI ini = new Core.INI(workDir + "config.tmp"); StringCollection dirs = new StringCollection(); ini.ReadSection("Dirs", dirs); foreach(var item in dirs) { Directory.CreateDirectory(item.Replace("~", workDir)); } MessageBox.Show(dirs.ToString()); StringCollection files = new StringCollection(); ini.ReadSection("Files", files); foreach(var item in files) { FileInfo fileInfo = new FileInfo(item.Replace("~", workDir)); if (!fileInfo.Directory.Exists) Directory.CreateDirectory(fileInfo.Directory.FullName); var bytes = reader.ReadBytes(ini.ReadInteger("Files", item, 0)); File.WriteAllBytes(fileInfo.FullName, bytes); } reader.Close(); //Directory.Delete(workDir, true); }
/** * ȡ�ò����ַ����� * * @param argTypes * @return */ public static string ArgumentTypesToString(Type[] argTypes) { StringCollection buf = new StringCollection(); buf.Add("("); if (argTypes != null) { for (int i = 0; i < argTypes.Length; i++) { if (i > 0) { buf.Add(", "); } Type t = argTypes[i]; buf.Add((t == null) ? "null" : t.Name); } } buf.Add(")"); return buf.ToString(); }
void bbi_Drop(object sender, DragEventArgs e) { System.Windows.Point pt = e.GetPosition(sender as IInputElement); if ((sender as BreadcrumbBarItem).ShellObject.IsFileSystemObject) { if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey) { e.Effects = DragDropEffects.Copy; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName; AddToLog("Copied Files to " + PasteData.PathForDrop + " Files copied: " + scol.ToString()); Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } } else { //if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) == // Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName)) //{ e.Effects = DragDropEffects.Move; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName; AddToLog("Moved Files to " + PasteData.PathForDrop + " Files moved: " + scol.ToString()); Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } //} //else //{ // e.Effects = DragDropEffects.Copy; // if (e.Data.GetDataPresent(DataFormats.FileDrop)) // { // DropData PasteData = new DropData(); // String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); // StringCollection scol = new StringCollection(); // scol.AddRange(collection); // PasteData.DropList = scol; // PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName; // Thread t = null; // t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); // t.SetApartmentState(ApartmentState.STA); // t.Start(PasteData); // } //} } } else { e.Effects = DragDropEffects.None; } DropTargetHelper.Drop(e.Data, pt, e.Effects); }