예제 #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         if (openFileDialog2.ShowDialog() == DialogResult.OK)
         {
             FileStream fs = File.Create(openFileDialog2.FileName);
             fs.Write(new byte[] { 80, 65, 67, 75 }, 0, 4); //PACK
             fs.WriteByte((byte)textBox2.Text.Length);
             fs.Write(Encoding.UTF8.GetBytes(textBox2.Text), 0, textBox2.Text.Length);
             int count = PackItems.Count;
             fs.Write(BitConverter.GetBytes(count), 0, 1);
             for (int i = 0; i < count; i++)
             {
                 PackItem item = PackItems[i];
                 fs.WriteByte((byte)item.path.Length);
                 fs.Write(Encoding.UTF8.GetBytes(item.path), 0, item.path.Length);
             }
             fs.Flush();
             fs.Close();
             openFileDialog2.FileName = "";
             MessageBox.Show("Written successfully");
         }
     }
     catch (Exception z) { MessageBox.Show("Error"); }
 }
예제 #2
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex >= 0)
     {
         PackItem item = PackItems[listBox1.SelectedIndex];
         label3.Text = item.name;
     }
     else
     {
         label3.Text = "";
     }
 }
예제 #3
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         int count = openFileDialog1.FileNames.Length;
         for (int i = 0; i < count; i++)
         {
             if (openFileDialog1.FileNames[i].Contains(root))
             {
                 string   path = openFileDialog1.FileNames[i].Substring(rootlength);
                 PackItem item = new PackItem();
                 item.name = openFileDialog1.SafeFileNames[i];
                 item.path = path;
                 PackItems.Add(item);
                 listBox1.Items.Add(path);
             }
             else
             {
                 MessageBox.Show("File must be under the root directory");
             }
         }
         openFileDialog1.FileName = "";
     }
 }