使用标准文件夹方法处理错误的文件 [英] wrong file handling using standard folder method

查看:60
本文介绍了使用标准文件夹方法处理错误的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个新问题!

目前的应用已经运行了一年,今天我不得不改变它的一些功能,但不是设置的日志文件。我使用标准方法来显示文件夹系统,让用户选择放置日志文件的文件夹。在过去的几年中,这已经在许多程序中使用了
并且有效。但是今天:

the current app has been running for abt a year and today I had to change some of its functionality, but not the setup of the log file. I use standard methods to display the folder system an let the user select which folder to put the log file. This has been used in a number of prgrams over the last years and worked. But today:

- 在创建文件路径和名称时,根据VB2010 IDE,全局变量fpath1包含正确选择的文件路径和文件名。但是当Windows尝试打开这个文件时,它将从根doen到完整文件路径和名称的VB2010
文件夹的整个路径,这使得它完全无用且错误的组合,Windows当然无法打开。

- when chreating the file path and name, the global variable fpath1 contains, according to the VB2010 IDE the correctly selected file path and file name. BUT when Windows try to open this file, it ADDS the whole path from root doen to the VB2010 folder in fron of the correct filepath and name, which makes it a completely useless and wrong combination, what Windows of course cannot open.

在示例中,我有两个文件,fpath1和pfath2,它们的内容只有不同,而fpath2有额外的"_lbl"。在文件名中。这已经在一周前发挥作用了,但现在已经不行了。

In the example I have two files, fpath1 and pfath2 that only differs in content and that fpath2 has the additional "_lbl" in the file name. This has worked a week ago, but not any longer.

Windows7中的一些变化必定会导致这种情况发生。如何绕过这个??????

Some changes in Windows7 must have caused this. How to get around this??????

 Form6.ShowDialog()


            ' Declare a variable named theFolderBrowser of type FolderBrowserDialog.
            Dim theFolderBrowser As New FolderBrowserDialog
            ' Set theFolderBrowser object's Description property to
            '   give the user instructions.
            theFolderBrowser.Description = "Please select a folder to save the file."
            ' Set theFolderBrowser object's ShowNewFolder property to false when
            '   the a FolderBrowserDialog is to be used only for selecting an existing folder.
            theFolderBrowser.ShowNewFolderButton = False
            ' Optionally set the RootFolder and SelectedPath properties to
            '   control which folder will be selected when browsing begins
            '   and to make it the selected folder.
            ' For this example start browsing in the Desktop folder.
            theFolderBrowser.RootFolder = System.Environment.SpecialFolder.Desktop
            ' Default theFolderBrowserDialog object's SelectedPath property to the path to the Desktop folder.
            theFolderBrowser.SelectedPath = My.Computer.FileSystem.SpecialDirectories.Desktop
            ' If the user clicks theFolderBrowser's OK button..
            If theFolderBrowser.ShowDialog = Windows.Forms.DialogResult.OK Then
                ' Set the FolderChoiceTextBox's Text to theFolderBrowserDialog's
                '    SelectedPath property.
                'Received.Text = theFolderBrowser.SelectedPath'
            ' addera datum. klockslag till Pnamn    Pnamn_datumtid

            a = System.DateTime.Now.ToString("yyyy.MM.dd_HH:mm:ss")
            ' Pnamn = Form6.TextBox1.Text + "_" + a
            Pnamn = Form6.TextBox1.Text
            fpath1 = theFolderBrowser.SelectedPath + "\" + Pnamn + ".txt"





 FileOpen(2, fpath1, OpenMode.Append, OpenAccess.Write) 'save label file






使用VB作为补充的嵌入式应用程序开发人员

developer of embedded apps using VB as complement

推荐答案

这是我的错误,一开始我注意到的一个微妙的事情。问题解决了。
This was my error, a subtle thing I did notice at first. Problem solved.


这篇关于使用标准文件夹方法处理错误的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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