小编Rob*_*Rob的帖子

文件存在于WPF中

if (!File.Exists("SomeFile.exe"))
{
//Does not exists
}
Run Code Online (Sandbox Code Playgroud)

我有SomeFile.exe与exe相同的路径,但结果是不存在.

在Windows窗体中不会发生这种情况,是否会发生变化?

c#

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

File.Exists()返回false,但不在调试中

我在这里完全糊涂了,

我的代码抛出异常,因为File.Exists()返回false

public override sealed TCargo ReadFile(string fileName)
{
    if (!File.Exists(fileName))
    {
        throw new ArgumentException("Provided file name does not exist", "fileName");
    }
Run Code Online (Sandbox Code Playgroud)

Visual Studio在throw语句中断,我立即检查File.Exists(fileName)在即时窗口中的值.它回来了true.当我将断点拖回到if语句并再次执行时,它会再次抛出.

fileName是文件的绝对路径.我不是在创建文件,也不是写文件(它一直都在那里).如果我将路径粘贴到记事本中的打开对话框中,它会毫无问题地读取文件.

代码在后台工作程序中执行.这是我能想到的唯一复杂因素.我很肯定文件还没有在工作线程或其他地方打开过.

这里发生了什么?

.net c# backgroundworker visual-studio-2008

4
推荐指数
2
解决办法
9526
查看次数

MonoGame中的ContentLoadException

我一直在尝试使用Xamarin Studio在MonoGame中加载纹理.我的代码设置如下:

#region Using Statements
using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;

#endregion

namespace TestGame
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        //Game World
        Texture2D texture;
        Vector2 position = new Vector2(0,0);

        public Game1 ()
        {
            graphics = new GraphicsDeviceManager (this);
            Content.RootDirectory = "Content";              
            graphics.IsFullScreen = false;      
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to …
Run Code Online (Sandbox Code Playgroud)

c# xna monogame

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

如何在wpf中更改应用程序文化?

这是我的代码.

double value = double.Parse(Utility.GetParamValueOrDefault(omRecord.paramList[i].value, "0"),CultureInfo.CurrentCulture);
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误 FormatException:输入字符串格式不正确

我已经阅读了StackOverFlow的一些线程,说我需要将以下代码添加到我的WPF应用程序的main()中.

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
Run Code Online (Sandbox Code Playgroud)

我仍然得到同样的错误,我的CurrentCulture仍然不是en-US.

c# wpf cultureinfo

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

ValueError:无法使用带有pandas的isin从重复轴重新索引

我试图将zipcodes缩短为各种文件,但我一直在努力

ValueError:无法从重复轴重新索引

我已经阅读了Stackoverflow上的其他文档,但我还没有弄清楚为什么它的重复轴.

import csv
import pandas as pd
from pandas import DataFrame as df
fp = '/Users/User/Development/zipcodes/file.csv'
file1 = open(fp, 'rb').read()
df = pd.read_csv(fp, sep=',')

df = df[['VIN', 'Reg Name', 'Reg Address', 'Reg City', 'Reg ST', 'ZIP',
         'ZIP', 'Catagory', 'Phone', 'First Name', 'Last Name', 'Reg NFS',
         'MGVW', 'Make', 'Veh Model','E Mfr', 'Engine Model', 'CY2010',
         'CY2011', 'CY2012', 'CY2013', 'CY2014', 'CY2015', 'Std Cnt', 
        ]]
#reader.head(1)
df.head(1)
zipBlue = [65355, 65350, 65345, 65326, 65335, 64788, 64780, 64777, 64743,
64742, 64739, 64735, 64723, …
Run Code Online (Sandbox Code Playgroud)

python dataframe pandas

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

如何调用async Task <bool>方法?

这是我创建的异步函数,这里在将这个函数强加到按钮上时出现错误.

public async Task<bool> Login(string UserName, string Password)
    {
        try
        {
            ParseUser User = await ParseUser.LogInAsync(UserName, Password);
            System.Windows.Forms.MessageBox.Show(User.ObjectId);
            var currentUser = ParseUser.CurrentUser;
            return true;
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.Message);
            return false;
        }           
    }
Run Code Online (Sandbox Code Playgroud)

调用时收到错误.

private void btnLogin_Click(object sender, EventArgs e)
    {
        if (Login(txtUserName.Text,txtPassword.Text))
        {
            MessageBox.Show("Login Success");                       
        }            
    }
Run Code Online (Sandbox Code Playgroud)

c# winforms parse-platform

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

通过部分匹配其名称来查找多个控件

我目前有 100 多个标签,名称如下:

labelNumber1 
labelNumber2 
labelNumber3 
labelNumber4 
....
labelLetter1
labelLetter2 
labelLetter3 
labelLetter4
....
Run Code Online (Sandbox Code Playgroud)

How would I find all the labels that have "Number" in the controls name? Instead of having to type out labelNumber1.text = "hello", etc.

I have tried regex and foreach with wild cards but did not succeed. I have looked on msdn.microsoft.com about using regex with a control.

c# winforms .net-4.5

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

你如何将QDialog粘贴到自定义代理中?

当您创建自己的自定义委托时,您实现createEditor(),setEditorData()setModelData().我面临以下问题.createEditor()我所看到的所有例子都使用QComboBox或QLineEdit等简单的东西,它们没有show()或没有exec()成员函数,每当我尝试使用QDialog时,程序都有未定义的行为(我认为)并且QDialog显示但是表现得很疯狂.我确实让我的程序工作,使用一些信号/插槽魔法,但我想使用所描述的标准模式实现它,例如,在这里:http://cep.xray.aps.anl.gov/software/ qt4-x11-4.2.2/model-view-delegate.html我该怎么办?

要详细说明当我面对未定义的行为时会发生什么,如果我在createEditor()中设置QDialog的父级,那么QDialog根本不会显示,如果我没有设置它,它会显示,然后当我将它拖到它周围时消失(这是错误的,我认为我必须始终设置父级,否则我将有内存泄漏).我想,现在我的问题归结为:我怎样才能使QDialog正确显示?我尝试将show()和exec()粘贴到setEditorData(),setModelData()和createEditor()的不同部分,但没有任何正常工作.

qt

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

超载!(砰)算子

在回答这个问题时,MathWorks支持团队指出:

也有可能超载!(bang)运算符通过创建一个名为"!.m"的文件,并将此文件放在MATLAB搜索路径中的$ MATLABROOT\toolbox\matlab\general目录之前.

我试过这个,似乎没有用.我在Linux Mint上运行Matlab 9.1.0.441655(R2016b).我的路径看起来像这样:

/home/raphael/Programs/Test
/usr/local/MATLAB/R2016b/toolbox/matlab/iofun
...
/usr/local/MATLAB/R2016b/toolbox/matlab/general
...
Run Code Online (Sandbox Code Playgroud)

我创建了一个文件!.m/home/raphael/Programs/Test.无论我在此文件中放置什么,编辑器都会显示错误:

Line 1: Unable to run code analysis. '/home/raphael/Programs/Test/!.m' is an invalid file name.
Run Code Online (Sandbox Code Playgroud)

作为!(bang)运算符未列在运算符和关联函数列表中,目前还不清楚!.m文件中的内容.

不过我还是尝试了一些代码:

function bang(c)

disp(c)
Run Code Online (Sandbox Code Playgroud)

虽然which !返回我的自定义文件路径,但Matlab总是调用内置运算符:

>> which !
/home/raphael/Programs/Test/!.m

>> !pwd
/home/raphael/Programs/Test
Run Code Online (Sandbox Code Playgroud)

重命名文件以bang.m解决错误但对bang运算符没有影响.

所以:

  • 自R2012以来,Matlab的行为是否发生了变化?
  • 怎么会超载!(砰)算子?
  • 如果这实际上是可能的,那么函数声明的语法应该是什么?

matlab operator-overloading

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

将Bootstrap从3.3.4升级到4.0

我曾经拥有自己的网站Boostrap 3.3.4,因为我搬到了Bootstrap 4一切都被打破了.

基本上我的网站结构非常简单,一个包含一些jumbotrons和一些的容器panels

<body>
    <section class="container">
        <div class="jumbotron vertical-center">
            <div><img src="img/hello.jpg" style="width: 35%" class="img-responsive" title="Hello" alt="World"></div>
            <h2>my website!!</h2>
            <div class="panel panel-default">
                <div class="panel-body">
                    <h4> stackoverflow </h4>

                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-body">
                    <h4><span class="glyphicon glyphicon-education" aria-hidden="true"></span><strong> This is reall cool! </h4>
                </div>
            </div>
Run Code Online (Sandbox Code Playgroud)

等等.

CSS很简单

.container {
  max-width: 600px;
  background:white;
  padding: 30px 30px;
  text-align: center;
  background: transparent;
}

.jumbotron {
  background: white;
}
Run Code Online (Sandbox Code Playgroud)

在这里,我将有一套中心,响应良好的块(带有roundede边缘),不会占用屏幕的整个宽度.

我不知道如何适应Bootstrap 4 …

html css twitter-bootstrap-3 bootstrap-4

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