从特定位置加载diolog框 [英] Load a diolog box from a specific location

查看:181
本文介绍了从特定位置加载diolog框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


好吧所以我正在开发一个工具,它可以节省游戏中的字节数,然后你可以加载它们一切正常,


但问题是它不会从特定位置加载它会很棒,如果有人可以帮我清理代码并且


打开到。\Classes \\ \\ n 



感谢任何帮助的人                               :D







public void SaveFile(byte [] bytes)

        {

            saveFileDialog1.ShowDialog();

            File.WriteAllBytes(saveFileDialog1.FileName,bytes);

        }


        public byte [] LoadFile()

        {

            openFileDialog1.ShowDialog();

            return File.ReadAllBytes(openFileDialog1.FileName);

        }

解决方案

嗨 等待,



>>好吧所以我正在开发一个工具,它可以从游戏中保存字节,然后你可以加载它们所有有用的东西,



但问题是它不会从特定位置加载它会很棒,如果有人可以帮我清理代码并



OpenFileDialog.InitialDirectory
可用于设置默认目录。它可以获取或设置文件对话框显示的初始目录。



您可以将保存上一个文件的目录保存为初始目录。以下示例供您参考。

   const string directory = @" D:\ testvideo";   
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = directory;
if(openFileDialog1.ShowDialog()== System.Windows.Forms.DialogResult.OK)
{
string selectedDirectory = System.IO.Path.GetDirectoryName(openFileDialog1.FileName);
if(selectedDirectory!= directory)
{
System.Windows.MessageBox.Show(" Wrong folder selected!");
返回;
}
}


此外,如果您可以通过将有用的帖子标记为答案来关闭该帖子,将不胜感激。如果您有新问题,可以开始新的主题 包含所有必要的代码段,以便其他任何人能够从头开始重现您的问题
以及有关结果的详细说明,包括任何异常消息。



感谢您的理解。



最好的问候,



Yong Lu







ok so im working on a tool where it can save bytes from a game and then you can load them well all that works ,

but the problem is it wont load from a specific location it would be awesome if some one could help me clean the code up and

open up to .\Classes\aw 

thanks to anyone who helps                               :D

public void SaveFile(byte[] bytes)
        {
            saveFileDialog1.ShowDialog();
            File.WriteAllBytes(saveFileDialog1.FileName, bytes);
        }

        public byte[] LoadFile()
        {
            openFileDialog1.ShowDialog();
            return File.ReadAllBytes(openFileDialog1.FileName);
        }

解决方案

Hi  waested,

>>ok so im working on a tool where it can save bytes from a game and then you can load them well all that works ,

but the problem is it wont load from a specific location it would be awesome if some one could help me clean the code up and

OpenFileDialog.InitialDirectory can be used to set a default directory . It can get or set the initial directory displayed by the file dialog box.

You can save the directory where the previous file was saved as the initial directory. The following sample for your reference.

            const string directory = @"D:\testvideo";
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = directory;
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string selectedDirectory = System.IO.Path.GetDirectoryName(openFileDialog1.FileName);
                if (selectedDirectory != directory)
                {
                    System.Windows.MessageBox.Show("Wrong folder selected!");
                    return;
                }
            }

Besides, It would be appreciated if you could close the thread by marking helpful posts as an answer. If you have a new question you can start a new thread  with all necessary code snippets for anyone else to be able to reproduce your issue from scratch along with a detailed description about the results including any exception messages.

Thank you for your understanding.

Best Regards,

Yong Lu


这篇关于从特定位置加载diolog框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆