【问题标题】:mIRC script running a C# program, but getting a FileNotFound error运行 C# 程序的 mIRC 脚本,但收到 FileNotFound 错误
【发布时间】:2014-10-29 18:04:44
【问题描述】:

我正在尝试为我的频道设置一个 mIRC 机器人,而我当前的项目是在发生特定事件时在我的计算机上播放音频文件。

我编写了一个简短的 C# 控制台应用程序,它从参数中获取文件名并播放该文件。

这可以从 cmd 或使用快捷方式运行它,但是当我在我的频道上输入命令时,程序会启动,但会引发 FileNotFound 异常。

我使用 try{} catch{} 编写了一些代码来查看到底发生了什么。如果文件无法播放,它将首先列出提供的参数、扩展名(我稍后会更改),最后是组合字符串。它想出了什么:

args[0]: audiofile
extension: .wav
filename: audiofile.wav

这正是文件名,并且可以在命令行中完美播放。

有人知道这里发生了什么吗?

static void Main(string[] args)
{
    string extension = ".wav";
    string filename = "null";
    if (args == null || args.Length == 0)
    {
        Console.WriteLine("No arguments provided!");
        Console.ReadLine();
        return;
    }
    filename = args[0] + extension;
    Console.Write("Press enter to play grenade... ");
    Console.ReadLine();
    try
    {
        Console.WriteLine("Playing file " + filename);
        (new SoundPlayer(filename)).Play();
    }
    catch 
    {
        Console.WriteLine("Error!");
        Console.WriteLine("args[0]: " + args[0]);
        Console.WriteLine("extension: " + extension);
        Console.WriteLine("filename: " + filename);
    }
    Console.ReadLine();
}

mIRC 脚本:

on $*:text:!grenade:#: {
  /run "c:/users/electrospeed/documents/visual studio 2013/projects/audioplayer/audioplayer/bin/debug/audioplayer.exe" audiofile
}

【问题讨论】:

  • 你当前的工作目录是什么?
  • 我只是从 Visual Studio 的项目文件夹中运行它,所以 Documents/Visual Studio 2013/Projects/AudioPlayer/Audioplayer/bin/debug/

标签: c# visual-studio mirc


【解决方案1】:

在 mIRC 代码中,你在最后写了 audiofile,如果我错了,请纠正我,但我猜你的意思是 %audiofile 就像在变量中一样。

【讨论】:

    【解决方案2】:

    我认为您不需要目录路径中的引号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 2013-10-02
      • 1970-01-01
      • 2017-03-25
      相关资源
      最近更新 更多