Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

srikanth tekumudi

Junior< Frontend Developer at Phenom /> || Mock Interviewer || Javascript || to teach React || Content Creator
Ask srikanth tekumudi
102 Visits
3 Followers
0 Questions
Home/ srikanth tekumudi/Followers Answers
  • About
  • Questions
  • Answers
  • Best Answers
  • Posts
  • Polls
  • Asked Questions
  • Followed
  • Favorites
  • Comments
  • Followers Questions
  • Followers Answers
  • Followers Posts
  • Followers Comments
  1. Asked: September 9, 2021In: C#

    Remove the extension from a file name in C#

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:32 pm

    You can use Path.GetFileNameWithoutExtension: DirectoryInfo dirInfo = new DirectoryInfo(currentDirName); FileInfo[] smFiles = dirInfo.GetFiles("*.txt"); foreach (FileInfo file in smFiles) { builder.Append(Path.GetFileNameWithoutExtension(file.Name)); builder.Append(", "); }

    You can use Path.GetFileNameWithoutExtension:

    DirectoryInfo dirInfo = new DirectoryInfo(currentDirName);
    FileInfo[] smFiles = dirInfo.GetFiles(“*.txt”);

    foreach (FileInfo file in smFiles)
    {
    builder.Append(Path.GetFileNameWithoutExtension(file.Name));
    builder.Append(“, “);
    }

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: September 9, 2021In: C#

    How to get last 4 characters from string in C#?

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:08 pm

    use the substring() method to get the last 4 characters str.Substring(str.Length - 4);

    use the substring() method to get the last 4 characters

    str.Substring(str.Length – 4);

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: September 9, 2021In: ASP .NET

    How can update the values of a collection using LINQ in ASP.NET?

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:07 pm

    We can make use of ForEach extension method which is available as part of LINQ. collection.ToList().ForEach(o => o.PropertyToSet = value); The ToList is needed in order to evaluate the select immediately due to lazy evaluation

    We can make use of ForEach extension method which is available as part of LINQ.

    collection.ToList().ForEach(o => o.PropertyToSet = value);

    The ToList is needed in order to evaluate the select immediately due to lazy evaluation

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  4. Asked: September 9, 2021In: ASP .NET

    No migrations configuration type was found in the assembly

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:05 pm

    After you run Enable-Migrations and the Configuration file is created, rebuild the project and run Enable-Migrations -Force again.

    After you run Enable-Migrations and the Configuration file is created, rebuild the project and run
    Enable-Migrations -Force again.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  5. Asked: September 9, 2021In: ASP .NET

    How to convert bytes to KB,MB, GB in .NET ?

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 10, 2021 at 12:01 pm

    using Log to solve the problem static String BytesToString(long byteCount) { string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB if (byteCount == 0) return "0" + suf[0]; long bytes = Math.Abs(byteCount); int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)))Read more

    using Log to solve the problem

    static String BytesToString(long byteCount)
    {
    string[] suf = { “B”, “KB”, “MB”, “GB”, “TB”, “PB”, “EB” }; //Longs run out around EB
    if (byteCount == 0)
    return “0” + suf[0];

    long bytes = Math.Abs(byteCount);
    int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
    double num = Math.Round(bytes / Math.Pow(1024, place), 1);
    return (Math.Sign(byteCount) * num).ToString() + suf[place];
    }

    Another solution

    This may not the most efficient way to do it, but it’s easier to read if you are not familiar with log maths, and should be fast enough for most scenarios.

    string[] sizes = { “B”, “KB”, “MB”, “GB”, “TB” };
    double len = new FileInfo(filename).Length;
    int order = 0;
    while (len >= 1024 && order < sizes.Length – 1) {
    order++;
    len = len/1024;
    }

    // Adjust the format string to your preferences. For example “{0:0.#}{1}” would

    // show a single decimal place, and no space.

    string result = String.Format(“{0:0.##} {1}”, len, sizes[order]);

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  6. Asked: September 8, 2021In: ASP .NET

    How to make Swagger Codegen work with .NET core

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 9, 2021 at 10:41 pm

    to integrate swagger codegen into your web api project you have to install "Swashbuckle.AspNetCore.Swagger" nuget package by following the steps below : right click your project and click manage nuget packages and install "Swashbuckle.AspNetCore.Swagger" nuget package OR right click in dependenciesRead more

    to integrate swagger codegen into your web api project you have to install “Swashbuckle.AspNetCore.Swagger” nuget package by following the steps below :

    right click your project and click manage nuget packages and install “Swashbuckle.AspNetCore.Swagger” nuget package

    OR

    right click in dependencies and click manage nuget packages and install “Swashbuckle.AspNetCore.Swagger” nuget package

    Then add the following code into your project startup class

    public void ConfigureServices(IServiceCollection services)

    {

    services.AddControllers();

    services.AddSwaggerGen(c =>

    {

    c.SwaggerDoc(“v1”, new OpenApiInfo { Title = “API”, Version = “v1” });

    });

    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

    {

    if (env.IsDevelopment())

    {

    app.UseDeveloperExceptionPage();

    app.UseSwagger();

    app.UseSwaggerUI(c => c.SwaggerEndpoint(“/swagger/v1/swagger.json”,            “API v1”));

    }

    app.UseRouting();

    app.UseEndpoints(endpoints =>

    {

    endpoints.MapControllers();

    });

    }

     

     

     

     

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  7. Asked: September 8, 2021In: General Questions

    How get wwwroot folder path from ASP.NET core

    Walaa Mohamed
    Walaa Mohamed Junior
    Added an answer on September 9, 2021 at 10:41 pm

    Step 1: You will need to import the following namespace. using Microsoft.AspNetCore.Hosting; Step 2: By Using IHostingEnvironment public class HomeController : Controller { private IHostingEnvironment Environment; public HomeController(IHostingEnvironment _environment) { Environment = _environment;Read more

    Step 1:
    You will need to import the following namespace.
    using Microsoft.AspNetCore.Hosting;

    Step 2:
    By Using IHostingEnvironment
    public class HomeController : Controller
    {
    private IHostingEnvironment Environment;
    public HomeController(IHostingEnvironment _environment)
    {
    Environment = _environment;
    }
    public IActionResult Index()
    {
    string wwwPath = this.Environment.WebRootPath;
    string contentPath = this.Environment.ContentRootPath;
    return View();
    }
    }

    By Using IWebHostEnvironment
    In the below example, the IWebHostEnvironment is injected in the Controller and assigned to the private property Environment and later used to get the WebRootPath and ContentRootPath.
    public class HomeController : Controller
    {
    private IWebHostEnvironment Environment;
    public HomeController(IWebHostEnvironment _environment)
    {
    Environment = _environment;
    }
    public IActionResult Index()
    {
    string wwwPath = this.Environment.WebRootPath;
    string contentPath = this.Environment.ContentRootPath;
    return View();
    }
    }

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp

Sidebar

Adv 250x250

Explore

  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Footer

Oraask

About

Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy
  • Terms & Conditions

Follow

Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

© 2019 Oraask. All Rights Reserved
With Love by Oraask.