删除非法字符后出现非法字符错误。 [英] Illegal Char error after illegal char's are removed.

查看:139
本文介绍了删除非法字符后出现非法字符错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,用户加载一个文件(txt或csv),在该程序中,它将新行和逗号作为新的对象分隔符读取。每个新对象都放入一个数组中,每次都创建一个新的数组对象。还有一些测试可以检查读入程序的数据,如果有不能用于文件或文件夹的字符,则返回错误。有一个选项可以清理正在读取的数据,它将读取一行数据,然后在其上运行几个替换语句以更改安全字符的非法字符。在我的代码的某处,它正在清理数据,替换非法字符,然后尝试从数组对象创建文件,但即使我已经清理了非法字符的数据,在创建时,visual studio正在吐出自己的错误说非法字符(不是我作为测试构建的错误)。任何关于为什么会这样的想法都非常感谢。贝娄是有问题的代码。

I''m writing a program that a user loads a file (txt or csv) in which it reads newlines and commas as new object delimiters. Each new object is put into an array creating a new array object each time. There is also several tests in place to check the data being read into the program to return an error if there are characters that can''t be used for a file or folder. There is an option to clean the data being read in which it will read a line of data, then run several replace statements on it to change illegal characters for safe characters. Somewhere in my code it is cleaning the data, replacing the illegal characters then trying to create files off the array objects but even though I''ve cleaned the data of illegal characters, upon creation, visual studio is spitting out its own error saying illegal characters (not the error I built as a test). Any ideas on why this might be are greatly appreciated. Bellow is the code in question.

展开 | 选择 | Wrap | 行号

推荐答案

的价值是什么string newFile?
What is the value of the string newFile?


用户在文本框中键入文件夹的名称(此文件夹不是存在的文件夹,而是将要创建的文件夹)

输入的名称存储为值newobject.ParentFolder

接下来,用户将浏览到已经存在的文件夹(即我的文档)

他们的文件夹的目录名称浏览到的存储为outputdir

下一步是程序将outputdir(浏览到文件夹的目录名称)与要创建的文件夹parentfolder

outputdir的组合。和父文件夹然后存储为newPath

程序然后在这行代码中构建用户新文件夹(给定项目的文件夹):
The user types in a text box a name of a folder (this folder is not one that exists but rather one that will be made)
The name typed in is stored as value "newobject.ParentFolder"
Next the user will browse to an already existing folder from which to work from (i.e. My Documents)
The directory name of the folder they browsed to is stored as "outputdir"
The next step is that the program combines the outputdir (directory name of browsed to folder) with the to-be-created folder "parentfolder"
This combination of "outputdir" and "parentfolder" is then stored as "newPath"
The program then builds the users new folder (the folder for the given project) in this line of code:
展开 | 选择 | Wrap | 行号


仍然没有回答我的问题。我理解你根据用户输入和其他变量构建字符串newFile的逻辑。这一切都很好,花花公子,但我想知道错误发生前字符串的值。我假设错误发生在以下行之一:
That still doesn''t answer my question. I understand your logic in building the string newFile based off user-input and other variables. That is all fine and dandy but I want to know the value of the string before the error occurs. I am assuming the error is occurring on one of the following lines:
展开 | 选择 | Wrap | 行号


这篇关于删除非法字符后出现非法字符错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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