botsokoy's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
11 (0.01 per day)
Joined:
26-June 12
Profile Views:
177
Last Active:
User is offline Oct 07 2012 05:25 PM
Currently:
Offline

Previous Fields

Country:
PH
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   botsokoy has not set their status

Posts I've Made

  1. In Topic: File Association for application

    Posted 7 Oct 2012

    View Postbotsokoy, on 07 October 2012 - 03:08 PM, said:

    View PostSkydiver, on 05 October 2012 - 02:15 PM, said:

    You still didn't answer our question about where you said you were debugging in the IDE and if you were setting the command line arguments.

    Anyway, since you've chosen to take a different tack on debugging your problem, we'll have to debug things the hard way:

    In your Main() method, even before the Application.EnableVisualStyles() call, add:
    MessageBox.Show("Attach to me");
    
    


    Rebuild and re-install your application. After you deploy you program, copy the .PDB file into the same directory that has your .exe file.

    Next, double click on your .pld file.


    The message box should show up.

    Start Visual Studio, and choose: Debug.Attach to Process... Is the process list, you should see your .EXE as one of the choices. Click "Attach". Visual Studio may ask you to point to where your source files are.

    Next, set a breakpoint on your line right before where you check the args.Length.

    Let your program run, and press OK on the message box. Your breakpoint should be hit. You can then inspect the args array variable to see what command line is being passed to you. You can further trace in, and or set breakpoints in the code where you are trying to open the file.

    This one was the output after all:
    args {string[0]} string[]
    args.Length 0

    FileCompressionandDecompression.exe!FileCompressionandDecompression.Program.Main(string[] args = {string[0]}) Line 23 C#

    So, the string that have been pass into my MainForm2.cs is 0.

    I can figure out now my problem. My problem is in the MainForm2.cs. In reading the file into my datagridview.
  2. In Topic: File Association for application

    Posted 7 Oct 2012

    View PostSkydiver, on 05 October 2012 - 02:15 PM, said:

    You still didn't answer our question about where you said you were debugging in the IDE and if you were setting the command line arguments.

    Anyway, since you've chosen to take a different tack on debugging your problem, we'll have to debug things the hard way:

    In your Main() method, even before the Application.EnableVisualStyles() call, add:
    MessageBox.Show("Attach to me");
    
    


    Rebuild and re-install your application. After you deploy you program, copy the .PDB file into the same directory that has your .exe file.

    Next, double click on your .pld file.


    The message box should show up.

    Start Visual Studio, and choose: Debug.Attach to Process... Is the process list, you should see your .EXE as one of the choices. Click "Attach". Visual Studio may ask you to point to where your source files are.

    Next, set a breakpoint on your line right before where you check the args.Length.

    Let your program run, and press OK on the message box. Your breakpoint should be hit. You can then inspect the args array variable to see what command line is being passed to you. You can further trace in, and or set breakpoints in the code where you are trying to open the file.

    This one was the output after all:
    args {string[0]} string[]
    args.Length 0

    FileCompressionandDecompression.exe!FileCompressionandDecompression.Program.Main(string[] args = {string[0]}) Line 23 C#

    So, the string that have been pass into my MainForm2.cs is 0.
  3. In Topic: File Association for application

    Posted 6 Oct 2012

    View PostSkydiver, on 04 October 2012 - 12:54 AM, said:

    What is the exact error, and an which line is it being reported on.

    Could you also post your real code. The code you posted above will only call MainForm() if there are no command line parameters, yet you are passing in args[0]. You should have gotten an IndexOutOfRangeException if that were your real code.


    program.cs
     static void Main(string[] args)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (args.Length == 0)
                {
                    Application.Run(new MainForm());
                }
                else 
                {
                    Application.Run(new MainForm2(args));
                }
                
            }
    

    MainForm2.cs
            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;
    using System.IO.Compression;
    using Ionic.Zip;
    using Ionic.Zlib;
    
    namespace FileCompressionandDecompression
    {
        public partial class MainForm2 : Form
        {
    
            public MainForm2(string[] args)
            {
                string filename = Path.GetFullPath(args[0]);
                string filePath = Path.GetFileName(args[0]);
                InitializeComponent();
                DataTable pldtable = new DataTable();
    
                //set datagridview columns
                pldtable.Columns.Add("Full Name");
                pldtable.Columns.Add("File Name");
                pldtable.Columns.Add("Compress Size");
                pldtable.Columns.Add("Readable Size");
                pldtable.Columns.Add("Date Modified");
                pldtable.Columns.Add("Uncompress Size");
                pldtable.Columns.Add("Type");
                if (args.Length == 0)
                {
                    MessageBox.Show("File don't Exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //enable compress button
                    //compress files and put it to datagridview
                }
                else
                {
                    tb.Text = filename;
                    openStatus.Visible = true;
                    using (ZipFile pld = ZipFile.Read(filePath))
                    {
                        foreach (ZipEntry en in pld)
                        {
                            openStatus.Text = string.Format("Reading: {0}", en.FileName);
                            openStatus.Update();
                            string fullFileName = en.FileName;
                            string extension;
                            string fileName;
                            extension = Path.GetExtension(fullFileName);
                            fileName = Path.GetFileName(fullFileName);
                            FileInfo fileInfo = new FileInfo(fullFileName);
                            string fileType = fileInfo.Name;
                            DirectoryInfo dir = Directory.GetParent(fullFileName);
                            string folderName = dir.Parent + "//" + fileName;
    
                            //set bytes size
    
                            string sizeReadable = en.CompressedSize.ToString() + " bytes";
                            string resultDecomp = en.UncompressedSize.ToString() + " bytes";
    
                            //add filename to rows
                            pldtable.Rows.Add(en.FileName, fileType, sizeReadable, en.CompressedSize, en.LastModified, resultDecomp, extension);
                            dgv.DataSource = pldtable;
                            dgv.Columns[3].Visible = false;
                            dgv.Columns[0].Visible = false;
                            dgv.Columns[1].Width = 150;
                            dgv.Columns[2].Width = 120;
                            dgv.Columns[4].Width = 120;
                            dgv.Columns[5].Width = 130;
                            dgv.Columns[6].Width = 63;
                            if (dgv.Rows.Count > 1)
                            {
                                int total = 0;
                                for (int i = 0; i < dgv.RowCount; i++)
                                {
                                    total += Convert.ToInt32(dgv.Rows[i].Cells[3].Value);
                                    totalSize.Text = total.ToString() + " bytes";
                                    totalFiles.Text = dgv.Rows[i].Index.ToString() + " files";
                                }
                            }
                        }
                    }
    
                }
    
                dgv.Sort(dgv.Columns[3], ListSortDirection.Descending);
                openStatus.Visible = false;
                appStat.Text = "Success opening file.";
            }
    
            public static TextBox tb = new TextBox();
            public static DataGridView dgv = new DataGridView();
            public static ToolStripButton removebtn = new ToolStripButton();
            public static ToolStripButton decompbtn = new ToolStripButton();
            public static ToolStripButton decompbtnHere = new ToolStripButton();
            public static ToolStripLabel appStat = new ToolStripLabel();
            public static Label totalFiles = new Label();
            public static Label totalSize = new Label();
            public static Label labelSize = new Label();
            public static Label openStatus = new Label();
    
            private void openToolStripMenuItem_Click(object sender, EventArgs e)
            {
                openFileDialog1.Title = "Open File";
                openFileDialog1.Filter = "Compressed Files (*.pld,*.zip)|*.pld;*.zip";
                openFileDialog1.FileName = "";
                if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                
                string sFilePath;
                sFilePath = openFileDialog1.FileName;
                string path = sFilePath;
                DataTable pldtable = new DataTable();
    
                //set datagridview columns
                pldtable.Columns.Add("Full Name");
                pldtable.Columns.Add("File Name");
                pldtable.Columns.Add("Compress Size");
                pldtable.Columns.Add("Readable Size");
                pldtable.Columns.Add("Date Modified");
                pldtable.Columns.Add("Uncompress Size");
                pldtable.Columns.Add("Type");
    
                if (sFilePath == "")
                    return;
    
                if (System.IO.File.Exists(sFilePath) == false)
                {
                    return;
                }
                else
                {
                    textBox1.Text = sFilePath;
                    label5.Visible = true;
                }
    
                //enable compress button
                toolStripButton4.Enabled = true;
                toolStripButton2.Enabled = true;
                toolStripButton6.Enabled = true;
                //compress files and put it to datagridview
                using (ZipFile pld = ZipFile.Read(sFilePath))
                {
                    foreach (ZipEntry en in pld)
                    {
                        label5.Text = string.Format("Reading: {0}", en.FileName);
                        label5.Update();
                        string fullFileName = en.FileName;
                        string extension;
                        string fileName;
                        extension = Path.GetExtension(fullFileName);
                        fileName = Path.GetFileName(fullFileName);
                        FileInfo fileInfo = new FileInfo(fullFileName);
                        string fileType = fileInfo.Name;
                        DirectoryInfo dir = Directory.GetParent(fullFileName);
                        string folderName = dir.Parent + "//" + fileName;
                        // resultPath = Path.GetDirectoryName(fullFileName);
    
                        //set bytes size
    
                        string sizeReadable = en.CompressedSize.ToString() + " bytes";
                        string resultDecomp = en.UncompressedSize.ToString() + " bytes";
    
                        //add filename to rows
                        pldtable.Rows.Add(en.FileName, fileType, sizeReadable, en.CompressedSize, en.LastModified, resultDecomp, extension);
                        dataGridView1.DataSource = pldtable;
                        dataGridView1.Columns[3].Visible = false;
                        dataGridView1.Columns[0].Visible = false;
                        dataGridView1.Columns[1].Width = 150;
                        dataGridView1.Columns[2].Width = 120;
                        dataGridView1.Columns[4].Width = 120;
                        dataGridView1.Columns[5].Width = 130;
                        dataGridView1.Columns[6].Width = 63;
                        if (dataGridView1.Rows.Count > 1)
                        {
                            int total = 0;
                            for (int i = 0; i < dataGridView1.RowCount; i++)
                            {
                                total += Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value);
                                TotalSize.Text = total.ToString() + " bytes";
                                TotalFiles.Text = dataGridView1.Rows[i].Index.ToString() + " files";
                            }
                        }
                    }
    
                }
    
                dataGridView1.Sort(dataGridView1.Columns[3], ListSortDirection.Descending);
                label5.Visible = false;
                appStatus.Text = "Success opening file";
            }
    
            private void toolStripButton1_Click(object sender, EventArgs e)
            {
                AddFile2 addFile = new AddFile2();
                addFile.ShowDialog();
            }
    
            private void toolStripButton5_Click(object sender, EventArgs e)
            {
                openFileDialog1.Title = "Open File";
                openFileDialog1.Filter = "Compressed Files (*.pld,*.zip)|*.pld;*.zip";
                openFileDialog1.FileName = "";
                if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
    
                string sFilePath;
                sFilePath = openFileDialog1.FileName;
                string path = sFilePath;
                DataTable pldtable = new DataTable();
    
                //set datagridview columns
                pldtable.Columns.Add("Full Name");
                pldtable.Columns.Add("File Name");
                pldtable.Columns.Add("Compress Size");
                pldtable.Columns.Add("Readable Size");
                pldtable.Columns.Add("Date Modified");
                pldtable.Columns.Add("Uncompress Size");
                pldtable.Columns.Add("Type");
    
                if (sFilePath == "")
                    return;
    
                if (System.IO.File.Exists(sFilePath) == false)
                {
                    return;
                }
                else
                {
                    textBox1.Text = sFilePath;
                    label5.Visible = true;
                }
    
                //enable compress button
                toolStripButton4.Enabled = true;
                toolStripButton2.Enabled = true;
                toolStripButton6.Enabled = true;
                //compress files and put it to datagridview
                using (ZipFile pld = ZipFile.Read(sFilePath))
                {
                    foreach (ZipEntry en in pld)
                    {
                        label5.Text = string.Format("Reading: {0}", en.FileName);
                        label5.Update();
                        string fullFileName = en.FileName;
                        string extension;
                        string fileName;
                        extension = Path.GetExtension(fullFileName);
                        fileName = Path.GetFileName(fullFileName);
                        FileInfo fileInfo = new FileInfo(fullFileName);
                        string fileType = fileInfo.Name;
                        DirectoryInfo dir = Directory.GetParent(fullFileName);
                        string folderName = dir.Parent + "//" + fileName;
                        //resultPath = Path.GetDirectoryName(fullFileName);
    
                        //set bytes size
    
                        string sizeReadable = en.CompressedSize.ToString() + " bytes";
                        string resultDecomp = en.UncompressedSize.ToString() + " bytes";
    
                        //add filename to rows
                        pldtable.Rows.Add(en.FileName, fileType, sizeReadable, en.CompressedSize, en.LastModified, resultDecomp, extension);
                        dataGridView1.DataSource = pldtable;
                        dataGridView1.Columns[3].Visible = false;
                        dataGridView1.Columns[0].Visible = false;
                        dataGridView1.Columns[1].Width = 150;
                        dataGridView1.Columns[2].Width = 120;
                        dataGridView1.Columns[4].Width = 120;
                        dataGridView1.Columns[5].Width = 130;
                        dataGridView1.Columns[6].Width = 63;
                        if (dataGridView1.Rows.Count > 1)
                        {
                            int total = 0;
                            for (int i = 0; i < dataGridView1.RowCount; i++)
                            {
                                total += Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value);
                                TotalSize.Text = total.ToString() + " bytes";
                                TotalFiles.Text = dataGridView1.Rows[i].Index.ToString() + " files";
                            }
                        }
                    }
    
                }
    
                dataGridView1.Sort(dataGridView1.Columns[3], ListSortDirection.Descending);
                label5.Visible = false;
                appStatus.Text = "Success opening file.";
            }
    
            private void toolStripButton4_Click(object sender, EventArgs e)
            {
                //decompress files with specific directory
                using (ZipFile pld = new ZipFile())
                {
                    string pldTodecomp = textBox1.Text;
                    string pathFile = pldTodecomp;
                    string fileDir;
                    fileDir = Path.GetDirectoryName(pathFile);
                    
                    using (ZipFile pld2 = ZipFile.Read(pldTodecomp))
                    {
                        foreach (ZipEntry en in pld2)
                        {
                            en.Extract(fileDir,
                                ExtractExistingFileAction.OverwriteSilently);
                        }
                    }
                    MessageBox.Show("Decompress file is complete", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = string.Empty;
                    dataGridView1.DataSource = string.Empty;
                    toolStripButton4.Enabled = false;
                    toolStripButton2.Enabled = false;
                    toolStripButton6.Enabled = false;
                    appStatus.Text = "Ready";
                    TotalSize.Text = "0";
                    TotalFiles.Text = "0";
                }
            }
    
            private void toolStripButton2_Click(object sender, EventArgs e)
            {
                DecompTo2 DecompFrm = new DecompTo2(this);
                DecompFrm.ShowDialog();
            }
    
            private void MainForm2_Load(object sender, EventArgs e)
            {
    
                toolStripButton4.Enabled = false;
                toolStripButton2.Enabled = false;
                toolStripButton6.Enabled = false;
                tb = textBox1;
                dgv = dataGridView1;
                removebtn = toolStripButton6;
                decompbtn = toolStripButton4;
                decompbtnHere = toolStripButton2;
                appStat = appStatus;
                dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                totalFiles = TotalFiles;
                totalSize = TotalSize;
                labelSize = label2;
                openStatus = label5;
            }
    
            private void exitToolStripMenuItem_Click(object sender, EventArgs e)
            {
                this.Dispose();
            }
    
            private void toolStripButton6_Click(object sender, EventArgs e)
            {
                string pathFile = textBox1.Text;
                if (this.dataGridView1.SelectedRows.Count > 0)
                {
                    DialogResult conDelete = MessageBox.Show("Are you sure you want to delete file?", "Delete",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (conDelete == DialogResult.Yes)
                    {
                        string toBeRemove = (dataGridView1.SelectedCells[0].Value.ToString());
    
                        using (ZipFile pld = ZipFile.Read(pathFile))
                        {
    
                            pld.RemoveEntry(toBeRemove);
                            pld.Save();
    
                        }
                        dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                        if (dataGridView1.Rows.Count > 1)
                        {
                            int total = 0;
                            for (int i = 0; i < dataGridView1.RowCount; i++)
                            {
                                total += Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value);
                                TotalSize.Text = total.ToString() + " bytes";
                                TotalFiles.Text = dataGridView1.Rows[i].Index.ToString() + " files";
                            }
                        }
                    }
                    else if (conDelete == DialogResult.No)
                    {
                        return;
                    }
                }
            }
        }
    }
    
    
    
  4. In Topic: File Association for application

    Posted 5 Oct 2012

    View PostSkydiver, on 04 October 2012 - 12:54 AM, said:

    What is the exact error, and an which line is it being reported on.

    Could you also post your real code. The code you posted above will only call MainForm() if there are no command line parameters, yet you are passing in args[0]. You should have gotten an IndexOutOfRangeException if that were your real code.

    When I double click the file that I want to open, it is still the same. The file which I double click did not display into my datagridview.
  5. In Topic: File Association for application

    Posted 4 Oct 2012

    View PostAdamSpeight2008, on 04 October 2012 - 05:46 AM, said:

    Are you trying to debug the actions of the command line parameters via the IDE? Have you set the command line parameters to pass it in the project properties?

    Yes, I was trying to debug the command line parameters via IDE. I also put a primary output into the command line for my installer. But the file from the external path cannot be read into my application. I think I missed something into my program codes. I follow the instructions from this blog http://social.msdn.m...b2-3da029b1cd46.

    View PostAdamSpeight2008, on 04 October 2012 - 05:46 AM, said:

    Are you trying to debug the actions of the command line parameters via the IDE? Have you set the command line parameters to pass it in the project properties?

    Yes, I was trying to debug the command line parameters via IDE. I also put a primary output into the command line for my installer. But the file from the external path cannot be read into my application. I think I missed something into my program codes. I follow the instructions from this blog http://social.msdn.m...b2-3da029b1cd46.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Application Programming
Full Name:
Larynill Ances
Years Programming:
1
Programming Languages:
PHP, Javascript, C#, VB.net, Flash

Contact Information

E-mail:
Click here to e-mail me
Yahoo:
Yahoo  larynillances@yahoo.com

Friends

botsokoy hasn't added any friends yet.

Comments

botsokoy has no profile comments yet. Why not say hello?