小编xDe*_*vil的帖子

C#中String的文件路径

我需要摆脱一个字符串驱动器,目录和扩展.虽然我经历的驱动器似乎无法让目录和扩展工作.

namespace ConsoleApplication1
{
    class GetMethods
    {
        public String GetDrive(String Path)
        {
            String Drive;
            Drive = Path.Substring(0, 2);
            Console.WriteLine("Drive: {0}", Drive);
            return Drive;
        }

        public String GetDirectory(String Path)
        {
            Console.WriteLine("Directorul: ");
            var start = Path.IndexOf(":") + 1;
            var match2 = Path.Substring(start, Path.IndexOf(".") - start);
            return Path;  
        }

        public String GetExtension(String Path)
        {
            String Extension;
            Extension = Path.Substring(0,3);
            Console.WriteLine("Extensia: {0}", Extension);
            return Extension;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            String Path;
            GetMethods G = new GetMethods();
            Console.WriteLine("Introduceti …
Run Code Online (Sandbox Code Playgroud)

c# string

1
推荐指数
1
解决办法
92
查看次数

C#在字符串中获取2个字符之间的文本

public String GetDirectory(String Path)
    {
        Console.WriteLine("Directorul: ");
        var start = Path.IndexOf(":") + 6;
        var match2 = Path.Substring(start, Path.IndexOf(".") - start);
        return Path;      

    }
Run Code Online (Sandbox Code Playgroud)

我需要获取此字符串中2个字符之间的路径字符串:"C:\ Documents\Text.txt"

我希望它在':'和'.'之间显示文字.最后如此:"\ Documents\Text"

c# string path

1
推荐指数
1
解决办法
1393
查看次数

ASP.NET MVC 5使用AJAX删除数据库中的Row

我试图使用Ajax删除表中的行,以便在我尝试删除表的一行时页面不刷新.这是我的代码,但是暂时按下Delete什么都不做:

控制器:

public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Main main = db.Mains.Find(id);
            if (main == null)
            {
                return HttpNotFound();
            }
            return View(main);
        }
[HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            Main main = db.Mains.Find(id);
            db.Mains.Remove(main);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
Run Code Online (Sandbox Code Playgroud)

风景:

<script>
$(document).ready(function () {
    $("#Delete").on("click", function () {
        var parent = $(this).parent().parent();
        $.ajax({
            type: "post",
            url: "@Url.Action("Delete","Main")",
            ajaxasync: true,
            success: function () {
                alert("success");
            },
            error: function (data) {
                alert(data.x);
            }
        }); …
Run Code Online (Sandbox Code Playgroud)

asp.net ajax asp.net-mvc jquery

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×2

string ×2

ajax ×1

asp.net ×1

asp.net-mvc ×1

jquery ×1

path ×1