【发布时间】:2009-11-30 06:05:36
【问题描述】:
我正在开发一个图形转换程序,设置一个列表框来读取目录中的文件名。该代码基于我的讲师的示例,因此我认为它可以正常工作,但似乎到处都会产生错误。我在 Google 上搜索了“错误 CS1519:类、结构或接口成员声明中的无效令牌‘,’”,但我发现看起来不适用。这里是:
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.IO;
namespace Transformer
{
public partial class Transformer : Form
{
/* Initialize parameters */
private bool drawAxes = true;
private bool drawGrid = true;
private List<ObjectSettings> dispObjects = new List<ObjectSettings>();
/* Initialize form */
public Transformer()
{
InitializeComponent();
}
private void Transformer_Load(object sender, EventArgs e)
{
}
/* Populate available objects listbox */
private int selFile = 0;
private string currentDir = Directory.GetCurrentDirectory();
// errors start around here
private string[] fileEntries = Directory.GetFiles(currentDir+@"\Objects");
foreach (string s in fileEntries) {
int start = s.LastIndexOf(@"\");
int end = s.LastIndexOf(@".");
availObjectsListBox.Items.Add(s.Substring(start + 1, end - start - 1));
} // end foreach
}
}
【问题讨论】: