Windows 6.5.3에서 작은 응용 프로그램을 개발 중입니다. 이를 위해서는 C 드라이브에서 하나의 XML 파일을 읽어야합니다. 파일을 읽으려고 할 때 아래 오류가 나타납니다. 파일 액세스를 확인했습니다. 괜찮아.C 드라이브에서 XML 파일 읽기
"값이 예상되는 범위 내에 있지 않습니다."
스택 추적
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
at System.Xml.Linq.XElement.Load(String uri, LoadOptions options)
at FREEMobile.frmMainMenu.frmMainMenu_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form._SetVisibleNotify(Boolean fVis)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.Run(Form fm)
at FREEMobile.frmMainMenu.Main()
CODE
Dim faciltyXML As XElement
Dim strFileName As String = "C:\Users\xs1969\Desktop\FREEMobile\FREEMobile\Facility.xml"
faciltyXML = XElement.Load(strFileName, LoadOptions.None)
편집 1 :
감사 CTACKE. 나는 다음과 같은 변화를했다. 잘 작동합니다.
Dim faciltyXML As XElement
Dim strAppDir As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
Dim strFullPathToMyFile As String = Path.Combine(strAppDir, "Facility.xml")
faciltyXML = XElement.Load(strFullPathToMyFile)
감사합니다. 나는 당신의 해결책을 따랐습니다. 잘 작동합니다. – Gansun