首页 > 解决方案 > C# | 在应解压缩文件的书面程序中出现错误“找不到路径的一部分”

问题描述

using System;
using System.IO.Compression;

namespace TF2DuckHitSound
{
    class Program
    {

        static void Main(string[] args)
        {
            int version = 1;
            string sourcePath = @".\TF2DuckHitSounds2.1\";
            string destPath = @".\steamapps\common\Team Fortress 2\tf\custom\";
            string sourceZIP = @".\TF2DuckHitSound2.1\duckhitsound.zip";
            string destPathAlt;
            bool destPathExist;


            Console.WriteLine($"Installer for TF2DuckHitsound. Version {version}");
            Console.WriteLine("Looking for TF2 Directory...");
            if (System.IO.Directory.Exists(destPath))
            {
                destPathExist = true;
            }
            else
            {
                destPathExist = false;
                Console.WriteLine("TF2 Directory not found!");
            }
            if (destPathExist == true)
            {
                ZipFile.CreateFromDirectory(sourcePath, sourceZIP);
                ZipFile.ExtractToDirectory(sourceZIP, destPath);
            }
            else
            {
                Console.WriteLine("Please enter the full path of your custom directory...");
                destPathAlt = Console.ReadLine();
                ZipFile.CreateFromDirectory(sourcePath, sourceZIP);
                ZipFile.ExtractToDirectory(sourceZIP, destPathAlt);
            }
            Console.ReadKey();

        }
    }
}

请帮忙。这是确切的错误代码:

找不到路径“C:\Users\luca-\OneDrive\Visual Studio\TF2DuckHitSound\TF2DuckHitSound\bin\Release\netcoreapp3.0\TF2DuckHitSound2.1\duckhitsound.zip”的一部分。

标签: c#.netvisual-studiozip

解决方案


推荐阅读