• 创建删除文件


    /// <summary>
            /// 创建文件
            /// </summary>
            /// <param name="p_posId"></param>
            /// <param name="p_posKey"></param>
            /// <param name="p_content"></param>
            /// <param name="p_jsonCode"></param>
            private static void CreateFile(int p_posId, string p_posKey, string p_content, ReturnJsonCode p_jsonCode)
            {
                StreamWriter sw = null;
                try
                {
                    string strJsPath = HttpContext.Current.Server.MapPath(string.Format("/js/{0}/", p_posId / 1000));
                    if (!Directory.Exists(strJsPath))
                    {
                        Directory.CreateDirectory(strJsPath);
                    }
                    sw = new StreamWriter(string.Format("{0}{1}.js", strJsPath, p_posKey), false, Encoding.UTF8);
                    sw.Write(p_content);
                    p_jsonCode.code = 1;
                    p_jsonCode.msg = "脚本生成成功";
                    p_jsonCode.data = string.Format("//{0}/js/{1}/{2}.js", ConfigurationManager.AppSettings["conDomain_a_com"], p_posId / 1000, p_posKey);
                }
                catch (Exception ex)
                {
                    p_jsonCode.msg = string.Format("脚本生成失败,错误内容:{0}", ex.Message);
                }
                finally
                {
                    if (sw != null)
                    {
                        sw.Close();
                    }
                }
            }
     /// <summary>
            /// 删除广告位脚本文件
            /// </summary>
            /// <param name="p_posId">广告位ID</param>
            /// <param name="p_posKey">广告位objectId</param>
            /// <returns></returns>
            public static ReturnJsonCode DelPosJs(int p_posId, string p_posKey)
            {
                ReturnJsonCode jsonCode = new ReturnJsonCode();
                if (p_posId <= 0 || string.IsNullOrWhiteSpace(p_posKey))
                {
                    jsonCode.msg = "参数错误";
                    return jsonCode;
                }
                string strJsPath = HttpContext.Current.Server.MapPath(string.Format("/js/{0}/{1}.js", p_posId / 1000, p_posKey));
                if (File.Exists(strJsPath))
                {
                    try
                    {
                        File.Delete(strJsPath);
                        jsonCode.code = 1;
                        jsonCode.msg = "删除广告文件成功";
                    }
                    catch (Exception ex)
                    {
                        jsonCode.msg = string.Format("删除广告文件失败,错误内容:{0}", ex.Message);
                    }
                }
                else
                {
                    jsonCode.msg = "广告文件不存在";
                }
                return jsonCode;
            }
  • 相关阅读:
    Python pydoc.py
    Python dir
    HTTPS Web配置举例
    Kubernetes 笔记 03 扫清概念
    一文总结 Linux 虚拟网络设备 eth, tap/tun, veth-pair
    一文掌握 Linux 性能分析之内存篇
    云计算底层技术之高性能集群
    利用 Linux tap/tun 虚拟设备写一个 ICMP echo 程序
    Linux 网络工具详解之 ip tuntap 和 tunctl 创建 tap/tun 设备
    [原创] 详解云计算网络底层技术——虚拟网络设备 tap/tun 原理解析
  • 原文地址:https://www.cnblogs.com/sophiel/p/9584990.html
Copyright © 2020-2023  润新知