开发者

open any file chosen after specific time [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I want my program to open the selected file which selected by filedialo1 after specified time any answer please

this is my code

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.Diagnostics;
using System.IO;

namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            string Chosen_File = " ";
        }
        public void timer1_Tick(object sender, EventArgs e)
        {
            string Chosen_File = 开发者_如何学CopenFileDialog1.FileName;

            Process.Start(Chosen_File);
            timer1.Enabled = true;
        }
    }
}

the erroer is The system cannot find the file specified


If you want the answer emailed to you, you can tick the box below your question.

The problem you have is that you're not saving the filename.

I would also have the timer initially disabled, to prevent it trying to open a file if the user cancels the dialog box. Also, don't forget to disable the timer in its tick event handler, otherwise the file will be opened multiple times.

string Chosen_File = null;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
    Chosen_File =  MyDialog.FileName;
    timer1.Enabled = true;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜