当前位置:编程学习 > C#/ASP.NET >>

100分求助,用C#生成torrent的时候怎么生成带文件夹的种子

RT!遇到一个问题,用C#生成多文件夹种子的时候,不管文件是否在文件夹下,生成出来的种子始终是在顶级的,不是在文件夹下面的,请问,怎么才能生成啊,最好有例子,谢谢了 --------------------编程问答-------------------- 自己顶一下~ --------------------编程问答-------------------- 感兴趣,帮顶。 --------------------编程问答-------------------- 没太明白,给你个我刚刚写的日志程序,就是将文件生成在文件夹下面的!先判断文件夹是否存在,不存在就生成一个文件夹,之类的你看了估计就懂了,不难

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Text;

namespace WebApplication10
{
    /// <summary>
    /// 日志管理
    /// </summary>
    public class LogManager
    {
        /// <summary>
        /// 日志写入
        /// </summary>
        /// <param name="type">日志类型</param>
        /// <param name="content">日志内容</param>
        public void WriteLog(LogType type, string content)
        {
            string filePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Logs\\" + DateTime.Now.ToShortDateString() + "\\";
            byte[] buffers = Encoding.Default.GetBytes(content);
            //判断当前文件夹是否存在,如果没有将创建文件夹
            if (Directory.Exists(filePath))
            {
                string strFilePath = "";
                if (type == LogType.AbnormalLog)
                {
                    strFilePath = filePath + "[异常]" + DateTime.Now.ToShortDateString() + ".txt";
                }
                if (type == LogType.InterfaceLog)
                {
                    strFilePath = filePath + "[接口]" + DateTime.Now.ToShortDateString() + ".txt";
                }
                if (type == LogType.WOLog)
                {
                    strFilePath = filePath + "[工单]" + DateTime.Now.ToShortDateString() + ".txt";
                }
                if (type == LogType.SystemLog)
                {
                    strFilePath = filePath + "[系统]" + DateTime.Now.ToShortDateString() + ".txt";
                }
                if (type == LogType.OtherLog)
                {
                    strFilePath = filePath + "[其他]" + DateTime.Now.ToShortDateString() + ".txt";
                }
                WriteStream(strFilePath, buffers);
            }
            else
            {
                Directory.CreateDirectory(filePath);
                WriteLog(type, content);
            }
        }
        /// <summary>
        /// 流写入日志
        /// </summary>
        /// <param name="path">写入路径</param>
        /// <param name="buffers">写入的文件流</param>
        private void WriteStream(string path, byte[] buffers)
        {
            FileStream fileStream = new FileStream(path, FileMode.Append);
            fileStream.Write(buffers, 0, buffers.Length);
            fileStream.Close();
        }
    }
    /// <summary>
    /// 日志类型
    /// </summary>
    public enum LogType
    {
        /// <summary>
        /// 异常日志
        /// </summary>
        AbnormalLog,
        /// <summary>
        /// 接口日志
        /// </summary>
        InterfaceLog,
        /// <summary>
        /// 工单日志
        /// </summary>
        WOLog,
        /// <summary>
        /// 系统日志
        /// </summary>
        SystemLog,
        /// <summary>
        /// 其他日志
        /// </summary>
        OtherLog,
    }
}
--------------------编程问答-------------------- 根据DirectoryInfo.Parent 属性 判断。。。。 --------------------编程问答-------------------- 楼上和楼上上都不对,种子文件不和一般的代码一样,如果是一般的代码我都知道,因为种子文件的解析不一样,所以都不对 --------------------编程问答--------------------
引用 5 楼 zl159467 的回复:
楼上和楼上上都不对,种子文件不和一般的代码一样,如果是一般的代码我都知道,因为种子文件的解析不一样,所以都不对

写错了,是不一样 --------------------编程问答-------------------- 自己顶一下~~
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,